How to set permission of all files in a bucket as public on every upload.

I am accessing DigitalOcean Spaces with the help of AWS SDK. I am able to connect and upload file to the Spaces bucket. I’m uploading a directory with recursive directories and files using ‘TransferManager.uploadDirectory()’ method. Is there a way to set permission as public as a part of uploading instead of iterating and setting individual object permission in another API call. But I want to set permission of all files which I’m uploading as ‘public’. By default it is ‘private’.

I tried using AWS bucket policy … but it is not supporting in DO Spaces. Also everytime I upload files to that particular bucket, I want all those files to be public.

Kindly help me with this. I’m searching for a generic solution. I’m not getting any way around.

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

i’m using, here is what i did.

	endpoint := ""
	accessKeyID := "access-key"
	secretAccessKey := "secret-access-key"
	useSSL := true

	// Initialize minio client object.
	minioClient, err := minio.New(endpoint, accessKeyID, secretAccessKey, useSSL)
	if err != nil {

	// Upload the file
	bucketName := "indonesia"
	newImageName := uuid.NewV4()
	objectName := "indonesia.jpg"
        fileObject := bytes.NewReader(body)
	contentLength := r.ContentLength
	contentType := r.Header.Get("Content-type")
	cacheControl := "max-age=31536000"
       // make it public
	userMetaData := map[string]string{"x-amz-acl": "public-read"}

	n, err := minioClient.PutObject(bucketName, objectName, fileObject, contentLength, minio.PutObjectOptions{ContentType: contentType, CacheControl: cacheControl, UserMetadata: userMetaData})
	if err != nil {

You can take a look at my Github repo to get a easy solution:

You have to specify ACL as public-read in the request headers:

‘x-amz-acl’: ‘public-read’