Upload S3 Object with Object Permissions

318 views Asked by At

I a using the .Net AWSSDK. I am trying to upload an object with permissions. In the console you can set permissions on an object by object basis and I can't for the life of me work out how to do it in C#.

I want an uploaded object to have Oped/Download permissions for everybody. So far I have the following:

try
{
    var fileTransferUtility = new TransferUtility(new AmazonS3Client(REGION));

    var fileName = Path.GetFileName(filePath);
    var key = path "/" + fileName;

    fileTransferUtility.Upload(filePath, existingBucketName, key);

    // Set open permissions for file with key
}
catch (AmazonS3Exception s3Exception)
{
    Console.WriteLine(s3Exception.Message, s3Exception.InnerException);
}
1

There are 1 answers

0
John Rotenstein On BEST ANSWER

Use this form of the Upload function:

public virtual void Upload(
         TransferUtilityUploadRequest request
)

The TransferUtilityUploadRequest contains a CannedACL property that can specify various different values such as:

  • Private
  • PublicRead
  • PublicReadWrite
  • AuthenticatedRead