简体   繁体   中英

NodeJS File Upload to Amazon S3 Store Mapping to Database

Im looking at Knox S3 library . In my web app, users are allowed to upload files. Im thinking of using Amazon S3.

In Knox, how to map the file uploaded to the user? Let say I want to know the files that a user uploaded. This will be stored in MongoDB.

Just an idea.

To figure out what data was uploaded by a specific user, you have two options:

  1. Use an external data store (MongoDB or any other database) and record the relation between the uploaded object on S3 (it's key) and the user. This data recording would be done by your app logic when a new object is uploaded to S3.

  2. Upload the data on S3 under a common prefix (eg all files uploaded by a user would be placed in /<user-id>/file.ext ) and do a LIST request on the bucket to find all the keys under that prefix.

Usually the first option works best, especially if you need to record multiple relations between your S3 objects and other entities.

These scenarios are not specific to using Knox as an S3 client. They apply independent of the programming language or S3 library.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM