Comments (4)
Alternatively if no extension is set on url, fallback to determining ext from content/type http header.
Added this functionality in 1.3.0. 21fd653
from react-native-image-cache-hoc.
It has rather naive file extension validation associated with the passed in url.
https://github.com/billmalarky/react-native-image-cache-hoc/blob/master/lib/FileSystem.js#L139
I'll update it to strip the query string as well as a quick patch, but the real solution is validating the actual downloaded file as a jpg/gif/png instead of validating using a file name extension (which doesn't even necessarily mean the file is what it says it is).
Or maybe I should remove this validation from the library entirely and leave validation up to the developer who integrates the library since true file validation will incur a slight performance hit.
Update: Recalling now the extension is required to be pulled and then set to local file hash filename extension, so this logic has nothing to do with mime type validation.
Patch could involve updating file extension extraction with a url parses to get a clean path to pull ext from:
https://www.npmjs.com/package/url-parse
Alternatively if no extension is set on url, fallback to determining ext from content/type http header.
While I'm here I may as well include bmp in the allowed types since native <Image> supports bmp.
The currently supported formats are png, jpg, jpeg, bmp, gif, webp (Android only), psd (iOS only).
https://facebook.github.io/react-native/docs/image.html
from react-native-image-cache-hoc.
@billmalarky I think stripping the query string to grab the file extension is a decent short term solution - still need the query string when actually fetching the image though.
There will almost certainly be a case whereby the file extension isn't in the URL. Like you said I don't think this library should be solving file type validation.
from react-native-image-cache-hoc.
Patched in: 0c690b0
Deployed in version 1.2.3
from react-native-image-cache-hoc.
Related Issues (20)
- Could not add resizeMode property to cacheable image HOT 5
- Usable with ImageBackground? HOT 6
- Image loading issue - Half images HOT 15
- app showing error while http url images in ios and android platform HOT 14
- Unable to determine remote image filetype HOT 4
- Static methods (cacheFile, flush) works only with default directory
- [Improvements] Request headers, filename, rejection callback
- how to get the cache size? HOT 3
- it will crash when given a wrong image uri HOT 2
- Make rn-fetch-blob a peer dependency
- Caching Folder absolute path
- Clear cache
- The image can't be cache if the link is in HTTP
- react-native link rn-fetch-blob throws error HOT 1
- Cacheable Image not working with ImageBackground which does not use a uri.
- [TypeError: Network request failed] in android HOT 1
- Getting the following exception when the image loads on iOS
- Warning: componentWillReceiveProps has been renamed HOT 1
- Caches images non-unique naming
- Package abandoned? HOT 3
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 react-native-image-cache-hoc.