I uploaded multiple PDF files in following path ( user/pdf/
) in AWS S3. So that path for each file is going to be like user/pdf/file1.pdf
, user/pdf/file2.pdf
, etc.
In my website(Angular front-end and Rails backend), I'm trying to do 3 things. 1) Retrieving files in certain path ( user/pdf/
). 2) Make a view which lists names of the files I retrieved from certain path. 3) Let users to click the name of the file and it will open the file using S3 endpoint 4) Delete the file by clicking a button.
I was looking into AWS S3 doc, but I could not find related API calls from the doc. Would love to get some help on performing above actions.
you should review the ruby S3 sdk doc
listing objects from a bucket
# enumerate ALL objects in the bucket (even if the bucket contains # more than 1k objects) bucket.objects.each do |obj| puts obj.key end # enumerate at most 20 objects with the given prefix bucket.objects.with_prefix('photos/').each(:limit => 20) do |photo| puts photo.key end
getting an object
# makes no request, returns an AWS::S3::S3Object obj = bucket.objects['key']
deleting an object
bucket.objects.delete('abc')
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.