直接到 s3/客户端文件上传。使用这种方法将未使用的文件存储在 s3 存储桶中是否有问题?
Direct to s3 / client file uploads. Is there a concern for storing unused files in your s3 bucket with this approach?
我正在查看 heroku(对于 NodeJs 应用程序)建议的本教程,用于通过服务器对 s3 文件进行签名,然后直接从客户端处理上传:
https://devcenter.heroku.com/articles/s3-upload-node
我想知道是否有许多未使用的文件存储在您的 s3 存储桶中。
在 heroku 教程中,他们 运行 通过用户编辑场景。他们说:
When a user selects an image to be uploaded, the upload to S3 is
handled automatically and asynchronously with the process described
earlier in this article. The image preview is then updated with the
selected image once the upload is complete and successful.
The user then clicks the “submit” button, which posts the username,
name and the URL of the uploaded image to the Node application to be
checked and/or stored. If no image was uploaded by the user earlier
the default avatar image URL is posted instead.
那么,如果用户选择了图像,然后在没有完成并提交用户个人资料信息的情况下单击到另一个页面怎么办?
那只是存储在您的 s3 存储桶中的浪费文件吗?
我在我的 MEAN 应用程序中使用了类似的方法,提交时:
我上传文件到S3。
然后,我承诺,上传完成后,我会提交用户的
配置文件信息 / post 与 s3 url 到服务器。
我也有类似的担忧,如果用户在 promise 调用之前离开或者存在连接问题怎么办——是否存在存储未使用文件的问题?
这是典型的处理方式吗,这只是风险的一部分?
在客户端进行上传这一事实不会使这个问题比在服务器端进行上传更糟。您仍然需要一种处理错误并保持与数据库同步的机制。
如何处理取决于您的具体应用需求。 @ceejayoz 提到了一种使用临时存储桶的方法。我宁愿在上传完成之前不担心上传,使用 Lambda 作业处理数据更新。如果您真的愿意,您也可以使用列表操作进行同步,但我认为这通常是不必要的。
我正在查看 heroku(对于 NodeJs 应用程序)建议的本教程,用于通过服务器对 s3 文件进行签名,然后直接从客户端处理上传:
https://devcenter.heroku.com/articles/s3-upload-node
我想知道是否有许多未使用的文件存储在您的 s3 存储桶中。
在 heroku 教程中,他们 运行 通过用户编辑场景。他们说:
When a user selects an image to be uploaded, the upload to S3 is handled automatically and asynchronously with the process described earlier in this article. The image preview is then updated with the selected image once the upload is complete and successful.
The user then clicks the “submit” button, which posts the username, name and the URL of the uploaded image to the Node application to be checked and/or stored. If no image was uploaded by the user earlier the default avatar image URL is posted instead.
那么,如果用户选择了图像,然后在没有完成并提交用户个人资料信息的情况下单击到另一个页面怎么办?
那只是存储在您的 s3 存储桶中的浪费文件吗?
我在我的 MEAN 应用程序中使用了类似的方法,提交时:
我上传文件到S3。
然后,我承诺,上传完成后,我会提交用户的 配置文件信息 / post 与 s3 url 到服务器。
我也有类似的担忧,如果用户在 promise 调用之前离开或者存在连接问题怎么办——是否存在存储未使用文件的问题?
这是典型的处理方式吗,这只是风险的一部分?
在客户端进行上传这一事实不会使这个问题比在服务器端进行上传更糟。您仍然需要一种处理错误并保持与数据库同步的机制。
如何处理取决于您的具体应用需求。 @ceejayoz 提到了一种使用临时存储桶的方法。我宁愿在上传完成之前不担心上传,使用 Lambda 作业处理数据更新。如果您真的愿意,您也可以使用列表操作进行同步,但我认为这通常是不必要的。