def main():
    content = BytesIO(b'Hello again')

    minio = Minio(STORAGE_ENDPOINT,
                  access_key=AWSAccessKeyId,
                  secret_key=AWSSecretKey)

    # Create an SSE-C object with a 32 byte customer_key
    key = b'32byteslongsecretkeymustprovided'
    ssec = SseCustomerKey(key)

    # Put object with SSE_C object passed as a param
    minio.put_object(STORAGE_BUCKET,
                     'test_crypt.txt',
                     content,
                     content.getbuffer().nbytes,
                     sse=ssec)

    # Copy encrypted object on Server-Side from Source to Destination
    obj = minio.copy_object(STORAGE_BUCKET,
                            'test_crypt_copy.txt',
                            STORAGE_BUCKET + '/test_crypt.txt',
                            source_sse=ssec,
                            sse=ssec)

    # Get decrypted object with SSE_C object passed in as param
    obj = minio.get_object(STORAGE_BUCKET, 'test_crypt_copy.txt', sse=ssec)

    print(obj.read())
Esempio n. 2
0
result = client.stat_object("my-bucketname", "my-objectname")
print(
    "last-modified: {0}, size: {1}".format(
        result.last_modified,
        result.size,
    ), )

# Get object information of version-ID.
result = client.stat_object(
    "my-bucketname",
    "my-objectname",
    version_id="dfbd25b3-abec-4184-a4e8-5a35a5c1174d",
)
print(
    "last-modified: {0}, size: {1}".format(
        result.last_modified,
        result.size,
    ), )

# Get SSE-C encrypted object information.
result = client.stat_object(
    "my-bucketname",
    "my-objectname",
    ssec=SseCustomerKey(b"32byteslongsecretkeymustprovided"),
)
print(
    "last-modified: {0}, size: {1}".format(
        result.last_modified,
        result.size,
    ), )