Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate upload/download pre-signed urls with the Disk util #1160

Open
k0rn4l opened this issue Oct 25, 2022 · 3 comments
Open

Generate upload/download pre-signed urls with the Disk util #1160

k0rn4l opened this issue Oct 25, 2022 · 3 comments

Comments

@k0rn4l
Copy link

k0rn4l commented Oct 25, 2022

We don't always want to server to handle file uploads, and it's easy enough to use the AWS SDK, but the Disk util is just too convenient. Would it be possible to add this feature to it?

Something like:

 const { downloadUrl } = await this.disk.createPresignedDownloadUrl('docs/xxx.pdf', 'buffer', {
              expiresIn: 3600
          });
 const { uploadUrl } = await this.disk.createPresignedUploadUrl('docs', content, {
              expiresIn: 3600
          });

Thought this does present a problem, to how to handle local file upload/downloads in this case, I don't have good idea for that one.

@kingdun3284
Copy link
Member

You can write your own disk that extends the original disk.

For example: https://github.com/codeperate/foal-s3-disk-v3/blob/main/src/s3-disk.service.ts

This is my own implementation that change the s3 disk service to use aws-sdk v3.

@LoicPoullain LoicPoullain added this to Backlog in Issue tracking via automation Nov 9, 2022
@LoicPoullain
Copy link
Member

Hi @k0rn4l 👋

Thank you for your suggestion.

I'm not very familiar with presigned upload/download URLs. Would you have some examples in mind that would show how it works in practice?

@k0rn4l
Copy link
Author

k0rn4l commented Apr 13, 2023

Hi @LoicPoullain !

So the idea here is to skip the processing of the uploaded file for the backend, and instead upload it directly to a storage bucket from the frontend ( or other service ). This can be done securely by getting a signed upload url via the AWS SDK from your backend, and send that URL to the frontend. The admin can then use that URL to upload files to the pre selected bucket/folder. The URL expires in the set amount of time.

Same for the download URL. A temporary download link is created, and you can download the contents from there until it expires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Issue tracking
  
Backlog
Development

No branches or pull requests

3 participants