Comments (4)
When you do any kind of direct uploads (custom endpoint, S3, tus), Shrine won't extract the metadata automatically, and will instead just use metadata that was set on the client side. This is because, in order to extract metadata, Shrine needs to retrieve the file contents (though determine_mime_type
and store_dimensions
plugins usually need just first few kilobytes). And that can potentially be expensive if the file is uploaded to remote storage like S3.
You can enable metadata extraction on attachment assignment by loading the restore_cached_data
plugin. This is useful if you want to validate the extracted metadata, but it means metadata extraction will happen in the foreground.
Shrine.plugin :restore_cached_data
Alternatively you can use the refresh_metadata
plugin (which restore_cached_data
uses internally) to trigger the extraction yourself. Then you could e.g. call it in a background job if you're using it, by putting it in the process step when cached file is uploaded to permanent storage:
Shrine.plugin :refresh_metadata
process(:store) do |io, context|
io.tap(&:refresh_metadata!) # return original cached file with extracted metadata
end
from shrine-tus.
from shrine-tus.
Worked like a charm, thanks!
from shrine-tus.
Yes, it's also the case with option C, as Shrine doesn't differentiate between storages, as it avoids storage-specific logic in order for the behaviour to stay the same when switching between different storages.
I will add the note about extracting metadata to the README.
from shrine-tus.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from shrine-tus.