-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Bug Report
When attempting to upload a file from Android and including params, I keep getting the following error:
"message":"The operation failed with an error - An unknown error occurred while trying to run the operation"
"code":"OS-PLUG-FLTR-0011"
Capacitor Version
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 7.4.3
@capacitor/core: 7.4.3
@capacitor/android: 7.4.3
@capacitor/ios: 7.4.3
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 7.4.1
@capacitor/android: 7.4.1
@capacitor/core: 7.4.1
[success] Android looking great! 👌
using @capacitor/file-transfer v1.0.6
Platform(s)
Android.
Not attempted on iOS.
Current Behavior
An exception is thrown before the file is uploaded.
Here is the simplified code attempting the upload:
const uri = (await Filesystem.getUri({directory: Directory.Data, path: 'image.jpg'})).uri;
const result = await FileTransfer.uploadFile({
url: 'https://my.backend.com/upload,
path: uri,
fileKey: 'file', // The key expected by the server for the file
headers: {
api_key: '...key...'
}, params: {
fileName: 'image.jpg'
}
});
Digging in, there is this exception being thrown:
java.lang.IllegalStateException: Cannot set request property after connection is made
The exception is in IONFLTRController.kt at line 284:
connection.setRequestProperty("Content-Type", mimeType)
Expected Behavior
File is uploaded without error.
Code Reproduction
Other Technical Details
Additional Context
Metadata
Metadata
Assignees
Labels
No labels