arc icon indicating copy to clipboard operation
arc copied to clipboard

Proposal: add `get` or `fetch` to storage

Open Gazler opened this issue 9 years ago • 7 comments

Currently the storage expects a url function to generate the URL which points to the uploaded file. However, there is no way to fetch an asset from the uploaded location. Once the asset has been uploaded, there is no way to get the asset from the storage location again.

An example of when this would be convenient is proxying requests. For example if you want to do some sort of permission check before allowing a user to download a file. You can do this on S3 with signed urls, but sometimes that is not desirable. Perhaps you wish to serve the content over a different protocol (such as a [web]socket.) In this case it would be nice if there was a convenient function to read the asset into memory from the storage location.

If this is something that you think is a good fit for the project then I can take a look at implementing it.

Gazler avatar Nov 16 '15 15:11 Gazler

If you want to get stuff from S3, you can drop to erlcloud_s3 and use:

:erlcloud_s3.configure('KEY', SECRET')
:erlcloud_s3.get_object('BUCKET', 'PATH')

nsomar avatar Dec 07 '15 18:12 nsomar

@oarrabi thanks. I am aware you can bypass arc. I was thinking it would be helpful to define it on the storage in the same way you can for put or url.

Gazler avatar Dec 07 '15 18:12 Gazler

I was a little surprised at the lack of a "retrieve" function as well (also using S3). Arc has a lot of out-of-the-box defaults for how to name files, creating the appropriate paths, etc, and they are not completely obvious to reproduce manually, splitting "bucket" and "path", particularly when dealing with "variants" (thumbnails, et al). It would be cleanest to have an Arc-based function to retrieve data, using all the same path constructions as used for storage, and particularly because storage could be configured to be local OR S3, if the retrieval functions are aware of that configuration, they can "do the right thing".

dotdotdotpaul avatar Jul 15 '16 16:07 dotdotdotpaul

I just started using arc and would love this functionality as well. I currently use ExAws directly to accomplish this but would be nice to have this done in arc.

I will see if I can put up a PR for this.

mayppong avatar Aug 01 '17 20:08 mayppong

Hi, @mayppong do you use ExAws.S3.download_file / ExAws.S3.get_object ?

psagan avatar Nov 22 '17 11:11 psagan

Yes, I am.

mayppong avatar Nov 23 '17 23:11 mayppong

+1

AlimovSV avatar Nov 20 '18 12:11 AlimovSV