apache / apache/cordova-plugin-file-transfer
not uploading on android 30
- Dominant language
- JavaScript
- Stars
- 606
- Forks
- 874
- PR merge metrics
- No merged PRs in 30d
Description
on android 10.0.0 using cordova-plugin-file-transfer 2.0.0-dev "File Transfer" and cordova-plugin-file 6.0.2 "File"
the upload from camera stoped working ... it worked before now with target 30 using android 10.0.0
i get Upload failed: Code = 1
using this code :
```
function uploadImage1() {
console.log("click em foto de perfil");
var nomevar1 = localStorage.getItem("reg_id");
var evento1 = "eventonome";
// Get URI of picture to upload
navigator.camera.getPicture(
function(uri) {
try {
// Pick image from div
var img = document.getElementById('pimage1');
img.style.visibility = "visible";
img.style.display = "block";
var imageURI = uri;
if (!imageURI || (img.style.display == "none")) {
console.log("Tap on picture to select image from gallery.");
return;
}
// Verify server has been entered
server = 'https://www.estaff.pt/mobile/uploads/mobile_upload.php'
console.log("Server "+server);
if (server) {
// Specify transfer options
var options = new FileUploadOptions();
options.fileKey="file";
options.fileName="perfil"+nomevar1;
options.mimeType="image/jpeg";
options.chunkedMode = false;
var params = {};
params.value1 = nomevar1;
params.value2 = evento1;
options.params = params;
// Transfer picture to server
var ft = new FileTransfer();
ft.onprogress = function(progressEvent) {
if (progressEvent.lengthComputable) {
var perc = Math.floor(progressEvent.loaded / progressEvent.total * 100);
$('.loading_pic').show();
$('#percentagem').html(perc);
console.log(perc);
if (perc == "99") {$('.loading_pic').hide();}
}
};
ft.upload(imageURI, server, function(r) {
console.log( "Upload successful: "+r.bytesSent+" bytes uploaded.");
img.src = uri;
img.width = 125;
img.height = 125;
},
function(error) {
console.log("Upload failed: Code = "+error.code);
}, options);
}
else {
console.log("Server Not Found");
}
}
catch(exce) {
alert(exce);
}
},
function(e) {
console.log("Error getting picture: " + e);
console.log("No Image Found");
},
{
quality: 85,
allowEdit: false,
correctOrientatin: true,
destinationType: navigator.camera.DestinationType.FILE_URI, targetWidth: 600,targetHeight: 600,
sourceType: navigator.camera.PictureSourceType.PHOTOLIBRARY,correctOrientation: true
}
);
}
```
any clues ?
Contributor guide
Research direction
Start with the reported uploadImage1 entry point and the FileTransfer.upload call, reproducing the failure on Android 10.0.0 with target 30, cordova-plugin-file-transfer 2.0.0-dev, and cordova-plugin-file 6.0.2. Trace the reported error code 1 and compare the camera-produced FILE_URI with the upload inputs; done means the camera image uploads successfully in the stated setup.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, javascript
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100