Exemple #1
0
def s3_upload(key_path, data_string, study_object_id, raw_path=False):
    if not raw_path:
        key_path = study_object_id + "/" + key_path
    data = encryption.encrypt_for_server(data_string, study_object_id)
    conn.put_object(Body=data,
                    Bucket=S3_BUCKET,
                    Key=key_path,
                    ContentType='string')
Exemple #2
0
def s3_upload(key_path, data_string, study_id, raw_path=False):
    """ Uploads data to s3, ensures data is encrypted with the key from the provided study.
    Takes an optional argument, raw_path, which defaults to false.  When false the study_id is
    prepended to the S3 file path (key_path), placing the file in the appropriate study folder. """
    if not raw_path: key_path = str(study_id) + "/" + key_path
    data = encryption.encrypt_for_server(data_string, study_id)
    key = _get_bucket(S3_BUCKET).new_key(key_path)
    key.set_contents_from_string(data)
Exemple #3
0
def s3_upload(key_path: str,
              data_string: bytes,
              study_object_id: str,
              raw_path=False) -> None:
    if not raw_path:
        key_path = study_object_id + "/" + key_path

    data = encrypt_for_server(data_string, study_object_id)
    conn.put_object(Body=data, Bucket=S3_BUCKET,
                    Key=key_path)  #, ContentType='string')
Exemple #4
0
def s3_upload(key_path,
              data_string,
              study_object_id,
              raw_path=False,
              encrypt=True):
    if not raw_path:
        key_path = study_object_id + "/" + key_path
    if encrypt:
        data = encryption.encrypt_for_server(data_string, study_object_id)
    else:
        data = data_string
        key_path += '.raw'

    try:
        conn.put_object(Body=data,
                        Bucket=S3_BUCKET,
                        Key=key_path,
                        ContentType='string')
        return True
    except:
        print 'S3.put_object Failed!'
        return False