def get_s3_content_and_delete(bucket, path, with_key=False):
 if is_botocore():
  import botocore.session
  session = botocore.session.get_session()
  client = session.create_client('s3')
  key = client.get_object(Bucket=bucket, Key=path)
  content = key['Body'].read()
  client.delete_object(Bucket=bucket, Key=path)
 else:
  import boto
  bucket = boto.connect_s3().get_bucket(bucket, validate=False)
  key = bucket.get_key(path)
  content = key.get_contents_as_string()
  bucket.delete_key(path)
 return ((content, key) if with_key else content)

def get_s3_content_and_delete ( bucket , path , with_key = False ) : if is_botocore ( ) : import botocore . session session = botocore . session . get_session ( ) client = session . create_client ( 's3' ) key = client . get_object ( Bucket = bucket , Key = path ) content = key [ 'Body' ] . read ( ) client . delete_object ( Bucket = bucket , Key = path ) else : import boto bucket = boto . connect_s3 ( ) . get_bucket ( bucket , validate = False ) key = bucket . get_key ( path ) content = key . get_contents_as_string ( ) bucket . delete_key ( path ) return ( ( content , key ) if with_key else content )
get content from s3 key .