agritheory / cloud_storage

S3 protocol storage for Frappe Applications - compatible with S3, Backblaze and DO Spaces
https://agritheory.com/documentation/cloud_storage
Other
9 stars 4 forks source link

Make time expiry configurable #7

Closed agritheory closed 1 year ago

agritheory commented 1 year ago

The time expiry feature should be configurable

Alchez commented 1 year ago

@agritheory, the files are fetched on-demand, and by default, the generated signed URL expires in 2 minutes. Is that what we're trying to adjust?

Looking at the botocore docs, it seems like we can give it an arbitrarily high value to avoid URL expiry.

agritheory commented 1 year ago

@Alchez Yes, a client in an area with poor connectivity and regularly handling large files may opt for a longer timeout.

For files that are public, we want to bypass the time expiry completely. I believe the right endpoint for this is download_file_obj, not generate_presigned_url.

Alchez commented 1 year ago

@agritheory, I tried out both download_fileobj and download_file and they don't give us URLs to redirect to. Instead, we just receive file data. The problem with that is we'll need to store it locally on the filesystem to be able to show the user the file.

Do we keep downloading a file everytime someone tries to fetch it? Should we store a reference to the local file in the File document once it's downloaded and re-use that? What do you think?

agritheory commented 1 year ago

Do we keep downloading a file everytime someone tries to fetch it?

No. The file URL should be set with this function and be streamed directly to the browser when provided with the URL.

Should we store a reference to the local file in the File document once it's downloaded and re-use that? There server only provides a redirect URL, there is no downloading.

No public files should be stored locally.