Comments (8)
I'm sorry, but I either didn't read your report completely or didn't think...
The problem with expo is, you can't use any libs that rely on native code (java, obejctive-c, ...) . And this lib does rely quite strong on native code. So you can't use it together with expo.
There are basically two possibilities now:
- You could eject it and by that get an app you can use normally with XCode or Android Studio, or any other IDE. (https://docs.expo.io/expokit/eject/)
- You rewrite it to use pure js.
Since you are currently only using it to upload a picture (or another file) this would be relatively easy.
I hand you a small snippet of code for doing so:
function send_file(fileuri, mimetype, filename){
let body = new FormData(),
data = {
uri: fileuri,
type: mimetype,
name: filename
};
body.append('file', data);
body.append('dirtkey', 'Hier bitte Müllwert einfügen');
return new Promise((resolve, reject) => {
let xhr = new XMLHttpRequest();
xhr.addEventListener('load', (x) => {
if (xhr.status >= 200 && xhr.status < 300) {
resolve(xhr.response);
}
else {
reject(xhr.statusText);
}
});
xhr.addEventListener('error', reject);
xhr.addEventListener('abort', reject);
xhr.open('POST', targeturi);
xhr.send(body);
});
}
Of course I would like you staying with my lib, but could understand that it's too much of a hassle for you. If you have some more questions, feel free to ask.
from react-native-blob-util.
thanks again for helping me out!
I tried it without headers and axios and also with XHR directly, same problem. Seems to me that formData only considers an append
when you specify 3 parameters. When I add the third, the following error is thrown:
TypeError: Failed to execute 'append' on 'FormData': parameter 2 is not of type 'Blob'.
So those lines don't create a blob object:
data = {
uri: fileuri,
type: mimetype,
name: filename
};
Which brings me back to the original state why I wanted to use your library :) So I did some more googling and came across the following code: https://github.com/schdief/reene/blob/a5ba1a9b9e01e53b4fdbcf7a23df91a5a928e7b4/reene/App.js#L222
This successfully transforms the URI to a blob and now it is recognized as an actual file at the backend.
Thanks again for all the help and sorry for not using your lib, have a nice day.
from react-native-blob-util.
It might be related to: #26
I assume it is built on linux, which actually cares about upper / lower case in path names. Whereas Windows (e.g. my development machine) does not care and could resolve the path correctly.
So please try if it still happens with the latest version.
from react-native-blob-util.
It might be related to: #26
I assume it is built on linux, which actually cares about upper / lower case in path names. Whereas Windows (e.g. my development machine) does not care and could resolve the path correctly.
yes I'm using MacOs
So please try if it still happens with the latest version.
I'm already using v0.13.6, did an update nevertheless, still same error
from react-native-blob-util.
The problem got fixed in v0.13.7. The lib is working well on iOS and simulators for iOS.
Could you post a minimal example so I can test it?
from react-native-blob-util.
The problem got fixed in v0.13.7. The lib is working well on iOS and simulators for iOS.
Could you post a minimal example so I can test it?
funny, yesterday I could only see 0.13.6 - updated to 0.13.7 now, still doesn't work, but slightly different error message:
you can find the whole app here, I have linked the line where I use your lib: https://github.com/schdief/reene/blob/129c836f2d77e07161072b4720d04d8c5b1e949b/reene/App.js#L43
it is still in it's early stages and I'm clearly no pro in reactive native
your help is much appreciated, thanks :)
from react-native-blob-util.
thanks a lot for the help @RonRadtke :)
I tried it before with native JS, but I couldn't get the picture to be recognized as a file at the receiving backend
the incoming request looks like this:
new request received:
{
fields: {
resprequ: '1',
dirtkey: 'sonst',
desc: 'Müll',
rlname: 'Lohr',
rfname: 'Steve',
remail: '',
rtel: '',
lat: '51.0529371',
lng: '13.7636763',
date: '2021-05-15T10:31:54.365Z',
file: '[object Object]'
},
files: {}
}
this output is generated by formidable and I would expect the file to be part of files
and not fields
, right?
you can see the backend logic here:
https://github.com/schdief/reene/blob/master/backend-mock/backend.js
the request in app is sent like this:
https://github.com/schdief/reene/blob/8c4db3c6147fc071972cf6637850d851f92f609d/reene/App.js#L84
although I'm not using your library anymore, I would be happy to get a hint what I'm doing wrong - thanks a lot :)
from react-native-blob-util.
I never worked with axios. So hard to say what the problem is. Compared to the stackoverflow entries (https://stackoverflow.com/questions/52830312/how-to-upload-image-to-server-using-axios-in-react-native) it seems ok. Might be your header though.
I tested my code with python flask, there it works fine and I get the file in the "files" element, not as field.
I would try to skip the headers for a test completely, to see if these are the problem. Seems to be the sole difference. Or trying pure xhr directly.
Also, it seems iOS is sometimes using 3 backslashes after file, so file:/// instead of file:// . You might have to check and correct this too
from react-native-blob-util.
Related Issues (20)
- Android Download Manager notification only shows up at the end
- response.json() is throwing an Error in Android saying No such file or directory HOT 1
- dest.exists() check fails in writeStream() in files of type content:// HOT 1
- Using writeStream() with content:// Uris HOT 1
- File gets corrupted with readStream() with base64 when using bufferSize defaults
- java to kotlin change example HOT 5
- pathForAppGroup typescript error HOT 1
- Error opening APK file: installation package is corrupt HOT 3
- Integration network debugging react-native-debugger HOT 1
- Crash when readStream on IOS
- Problem with java.lang.RuntimeException: java.lang.IllegalStateException: Use of own trust manager but none defined HOT 1
- wifiOnly option doesn't work on iOS as expected
- copyToMediaStore does not work on Android versions lower than 10 HOT 2
- Upload Video [Error: The operation couldn’t be completed. Message too long] HOT 3
- [Error: Unexpected FileStorage response file: null] on android 14 HOT 1
- Run error in windows, due to the WindowsTargetPlatformMinVersion
- ReactNativeBlobUtil.fs does not work if path contains 'content://' HOT 1
- How to get access to assets file (issue opened after trouble shooting read). HOT 2
- Android 14 PDF Issues HOT 1
- Cancel Download function not working HOT 5
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-blob-util.