Skip to content

Unsupported source URL  #143

@sagomezza

Description

@sagomezza

Hi,

I'm developing an React Native app with Expo, I'm trying to upload an image by diverse methods suggested in this issue:
https://github.com/cloudinary/cloudinary_js/issues/93
None of them gave me feedback about the problem (I was getting response 400), but actually the fetch method did. I'm getting Unsupported source URL when I'm passing the FileDirectory path of the image.

I don't know if maybe this has to do with this:
https://github.com/cloudinary/cloudinary_js/issues/130

Code:

uploadToCloudinary(id) {
const uri = FileSystem.documentDirectory + 'photos/Photo_' + id + '.jpg';
const url = "https://api.cloudinary.com/v1_1/aaaaaaaaa/image/upload/";
const formData = new FormData();
formData.append("file", uri);
formData.append("tags", vehicle);
formData.append("upload_preset", "aaaaaa");
formData.append("api_key", "1234567890");
fetch(url, {
method: 'POST',
body: formData
})
.then(response => {
console.log(response)
var reader = response.body.getReader();
var decoder = new TextDecoder();
var decodedValue;
function update() {
return reader.read().then(function(result) {
if (result.done) {
console.log(JSON.parse(decodedValue))
return (JSON.parse(decodedValue));
}
decodedValue = decoder.decode(result.value || new Uint8Array, {
stream: true
});
console.log(decodedValue)
return update();
});
}
return update();
});
}

Update: Now I tried a live example in pure JS. So it seems the file object us more complex than I thought. So, do I have to wait for a RN support or there is any workaround to this?.
Also I forgot to mention that I can't use an ImagePicker, because the image is a photo taken by the user.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions