问题描述:

I am working on Amazon S3 sdk for storing files on cloud server,i am using codeplex's threesharp(http://threesharp.codeplex.com) for implementing this, I have successfully uploaded file on server now i have to download it, and for this i have to download it with the URL eg https://s3.amazonaws.com/MyBucket/Filename

I can download the uploaded file but it is appearing blank, if i upload a text file then after downloading it's showing nothing in it,same as images and other files. I have read on Amazon S3 documentation that i'll have to make the object publically readable(http://docs.amazonwebservices.com/AmazonS3/latest/gsg/OpeningAnObject.html) i dont have any idea how to achieve this.

How can i accomplish the download functionality?

Threesharp project is a desktop based and i am working on web based application

网友答案:

During file upload set proper ACL:

Eg.:

AmazonS3 client = GetS3Client();
SetACLRequest request = new SetACLRequest();
request.BucketName = "my-new-bucket";
request.Key        = "hello.txt";
request.CannedACL  = S3CannedACL.PublicRead;
client.SetACL(request)

Amazon S3 provides a rich set of mechanisms for you to manage access to your buckets and objects.

Check this for detail: Amazon S3 Bucket Public Access Considerations

Also, You can Download Explorer for Amazon S3 (Eg. CloudBerry Explorer for Amazon S3) & they you can assign appropriate rights to your buckets.

CloudBerry Explorer for Amazon S3: Data Access Feature:

  • Bucket Policy Editor Create and edit conditional rules for managing access to the buckets and objects.

  • ACL Editor Manage access permission to any of your objects by setting up 'Access Control List'. ACL will also apply to all 'child objects' inside S3 buckets.

Also, you can do the same using Amazon S3 admin console.

Eg.

网友答案:

Have you tried the following:

  1. Right-click the object and click Make public
  2. Select the object and in the Permissions section checked Open/Download ?

edit:

have you taken a look here: How to set the permission on files at the time of Upload through Amazon s3 API

and here:

How to set a bucket's ACL on S3?

It might guide you in the right direction

相关阅读:
Top