I am using a space to store images for my web app. Those images need to be public so I can display them on the web app. How do I make those images public using the AWS SDK with Java? I know how to do it manually but obviously that is not scalable.
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.
The above answer does not really help. I figured it out on my own and here is the code snippet in case anybody else has this question.
This worked for me
Hello,
I have not done this with Java, but usually with Laravel for example, what I would do is to sue the
putFile
method, which allows you to pass the this as an argument:In your case what I could suggest is setting the
x-amz-acl
header topublic-read
that way each individual file would be available for everyone. For more information you could take a look at the documentation here:https://developers.digitalocean.com/documentation/spaces/#object
Or another option would be to set your listing permissions to public so that all files in that listing would be available by default:
https://www.digitalocean.com/docs/spaces/how-to/set-file-listing-permissions/
Hope that this helps! Regards, Bobby