apache / apache/cordova-plugin-file-transfer
No longer able to provide nested path
- Dominant language
- JavaScript
- Stars
- 606
- Forks
- 874
- PR merge metrics
- No merged PRs in 30d
Description
I believe https://github.com/apache/cordova-plugin-file-transfer/pull/310 broke the previous behaviour. It was possible to provide a nested path as target file. Now it will throw an error when doing so.
## Code to reproduce
```
(() => {
const fileTransfer = new FileTransfer();
const url = 'http://cordova.apache.org/static/img/cordova_bot.png'
const filePath = window.cordova.file.dataDirectory + 'nested/test.png';
fileTransfer.download(
url,
filePath,
file => console.log(file),
error => console.error(error)
);
})()
```
## Possible fix
Adding this code snippet after [line 727](https://github.com/kpatfln/cordova-plugin-file-transfer/blob/2cdb0403a81821e144998c8d9a00d338d6ece3ee/src/android/FileTransfer.java#L727)
```
if(file == null){
file = new File(targetUri.getPath());
}
file.getParentFile().mkdirs();
```
Contributor guide
Research direction
Start in src/android/FileTransfer.java around line 727 and reproduce the download using the nested target path shown in the issue. Check the target-file handling and verify that downloading to nested/test.png creates the parent directories without throwing an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, javascript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100