Open asiniy opened 8 years ago
Right now, when you upload a file via the multipart method, the file will be directly uploaded to the store
backend. To upload the file to the cache
backend, you have to use the PUT /attachments/cache
endpoint to upload the file outside the context of an ecto transaction.
In your case, you may be able to upload the file using that endpoint, set the file ID in to the changeset, then when you're done processing, you can upload it to the store backend. It may be a bit easier to write an Exfile.Processor
and put it in the list of preprocessor, though -- those will run before the file is uploaded.
I agree, this isn't ideal -- I made a mistake by uploading the file immediately when the file is assigned to the struct using Module.change/3
. I'll deal with this in #31 by automatically uploading to the cache backend first, then uploading to the store backend after the save to the DB has succeeded.
I can't get the logic of
cache
&store
backends. Inrefile
file is placed intocache
backend until record is stored, but it's working slightly different here.I'm implementing shot processor now, which is about taking frames of the videofiles due to specific time of video. I haven't extracted its logic from model yet.
The overall code looks like that (I'm inserting
process_shot
method to changeset):Here is the problem. I have a
exfile-b2
installed, and there are configs:In the changeset I'm supposing file to be stored in the local system according to
cache
backend system, but it doesn't. That's why my code makes roundtrip by downloading video from b2 and then uploading its shot back. This is definitely big price in the terms of both time and price for the traffic. What's wrong withcache
backend? How can I deal with my situation?