コード例 #1
0
def get_mpu(bucket, id, key_name):
    try:
        mpu = MultiPartUpload(bucket)
        mpu.id = id
        mpu.key_name = key_name
        return mpu
    except:
        return None
コード例 #2
0
def mp_from_ids(mp_id, filepath, bucket):
    """Get the multipart upload from the bucket and multipart IDs.
    This allows us to reconstitute a connection to the upload
    from within multiprocessing functions.
    """
    #conn = boto.connect_s3()
    #bucket = conn.lookup(mp_bucketname)
    #bucket = connection.get_bucket(bucketname, validate=False)
    mp = MultiPartUpload(bucket)
    mp.key_name = filepath
    mp.id = mp_id
    return mp
コード例 #3
0
def get_request_from_state(upload_id, upload_state, bucket):
    """ Fetches or creates a MultiPartUpload object for an upload ID. """
    if upload_state['status'] == UploadStates.NEW:
        upload_request = bucket.initiate_multipart_upload(
            upload_state['object'])
        new_state = {
            'status': UploadStates.IN_PROGRESS,
            'object': upload_state['object'],
            'id': upload_request.id
        }
        update_upload_state(upload_id, new_state)
    else:
        upload_request = MultiPartUpload(bucket=bucket)
        upload_request.id = upload_state['id']
        upload_request.key_name = upload_state['object']
    return upload_request
コード例 #4
0
def get_request_from_state(upload_id, upload_state, bucket):
    """ Fetches or creates a MultiPartUpload object for an upload ID.

    Args:
        upload_id: A string specifying the upload ID.
        upload_state: A dictionary containing upload state.
        bucket: A boto Bucket object.
    """
    if upload_state['status'] == UploadStates.NEW:
        upload_request = bucket.initiate_multipart_upload(
            upload_state['object'])
        new_state = {'status': UploadStates.IN_PROGRESS,
                     'object': upload_state['object'],
                     'id': upload_request.id}
        upsert_upload_state(upload_id, new_state)
    else:
        upload_request = MultiPartUpload(bucket=bucket)
        upload_request.id = upload_state['id']
        upload_request.key_name = upload_state['object']
    return upload_request
コード例 #5
0
def mp_from_ids(mp_id: str, mp_keyname: str, bucket: str) -> MultiPartUpload:
    mp = MultiPartUpload(bucket)
    mp.key_name = mp_keyname
    mp.id = mp_id
    return mp