Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
125 views
in Technique[技术] by (71.8m points)

javascript - Programmatically determine whether a file prefix exists in an S3 bucket

We're using AWS S3 to store file streams generated from MP3s. We want to spot check that the upload process worked correctly (ideally using a program in Node.js) by looping over a list of 'songIds' of ours and checking the bucket to make sure at least one file is in there corresponding to it.

So for example, a songId of 3423455 would have entries in the bucket starting with '35423455'-- they'd be called 35423455a1.ts, 35423455a2.ts...etc. All we want to see is if something in the bucket has a name starting with the songId.

I've looked at some of the docs and the listObjects [edit-- looks like 'listObjectsV2' is even better] method appears to have promise, would this be a good way to go about it? Can I use a file prefix in the params section of the method call?

question from:https://stackoverflow.com/questions/65831954/programmatically-determine-whether-a-file-prefix-exists-in-an-s3-bucket

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, listObjects is a perfect fit for this use case. Actually, it's better to use listObjectsV2.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...