triniwiz / nativescript-downloader

Apache License 2.0
32 stars 18 forks source link

Exception on setting fileName and path #21

Open DeepikaKochar opened 6 years ago

DeepikaKochar commented 6 years ago

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Whenever I try to pass fileName and path to createDownload method I receive this Exception :

An uncaught Exception occurred on "OkHttp Dispatcher" thread.
java.lang.StringIndexOutOfBoundsException: length=7; index=-1
    at java.lang.String.substring(String.java:1893)
    at co.fitcom.fancydownloader.ManagerService$1$1.onResponse(ManagerService.java:114)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
    at java.lang.Thread.run(Thread.java:761)

Is there any code involved?

       ```

var downloadId = this.downloader.createDownload({ url: url, path: this.fileservice.getImageFolderPath(), fileName: fileName }); console.log(File Id :${downloadId}); this.downloader.start(downloadId, (progressData: ProgressEventData) => { console.log(progressData.value); }).then(downloaderResponse => { console.log("completed "+JSON.stringify(downloaderResponse)); }).catch(error => { console.log("error in downloading "+JSON.stringify(error)); });.

triniwiz commented 6 years ago

What does the path and file name look like ?

Sent from Yahoo Mail for iPhone

On Monday, June 11, 2018, 1:06 AM, DeepikaKochar notifications@github.com wrote:

Which platform(s) does your issue occur on?

Please, provide the following version numbers that your issue occurs with:

Please, tell us how to recreate the issue in as much detail as possible.

Whenever I try to pass fileName and path to createDownload method I receive this Exception : An uncaught Exception occurred on "OkHttp Dispatcher" thread. java.lang.StringIndexOutOfBoundsException: length=7; index=-1 at java.lang.String.substring(String.java:1893) at co.fitcom.fancydownloader.ManagerService$1$1.onResponse(ManagerService.java:114) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) at java.lang.Thread.run(Thread.java:761)

Is there any code involved?



var downloadId = this.downloader.createDownload({
url: url,
path: this.fileservice.getImageFolderPath(),
fileName: fileName
});
console.log(File Id :${downloadId});
this.downloader.start(downloadId, (progressData: ProgressEventData) => {
console.log(progressData.value);
}).then(downloaderResponse => {
console.log("completed "+JSON.stringify(downloaderResponse));
}).catch(error => {
console.log("error in downloading "+JSON.stringify(error));
});.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
DeepikaKochar commented 6 years ago

path: '/data/user/0/BUNDLE.ID/fancy_downloader/' fileName: 'courseimage_20180608115442000000.jpg'

yringler commented 5 years ago

I'm having this same issue. Install on a real device, using angular. Path: /data/user/0/org.nativescript.RabbiGordonAudio/files filename: 0rdon1553774400

In my exception, the string length was 15, which is the length of my filename.

You can see the whole project here. I attempt to download in the media service.

Here's my versions (from tns doctor) √ Component nativescript has 5.3.0 version and is up to date. √ Component tns-core-modules has 5.3.1 version and is up to date. √ Component tns-android has 5.3.0 version and is up to date.

My version of the downloader: (from package-lock.json): "nativescript-downloader": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/nativescript-downloader/-/nativescript-downloader-2.1.4.tgz", "integrity": "sha512-WWa0U43FzD3K8a/+4JxKo1W1FT8X7IjMeSiWtLLjZ+NN33FoMYXz4l9xf6xGYBAiEcc71xVlh7LFnuIvrQ60vA==" }

Here's my exception: An uncaught Exception occurred on "OkHttp Dispatcher" thread. java.lang.StringIndexOutOfBoundsException: length=15; index=-1 at java.lang.String.substring(String.java:1935) at co.fitcom.fancydownloader.ManagerService$2$1.onResponse(ManagerService.java:141) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:153) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764)

Thank you for this plugin! If the problem is specifying path and name, I might experiment with leaving those out and moving the file where I want after. I'll try taking a look at the java files.

yringler commented 5 years ago

Update: I worked around by not specifying the file name, and then renaming it after the download is finished.

Here's the commit where I put in the workaround.

I would still love to try to fix the bug in the plugin, but now that I have a workaround it isn't as high priority 🙈 Isn't that the way of things.

wendt88 commented 4 years ago

wow it seems one of the worst plugins for NS. wrong readme, a lot of breaking bugs, and it never gets an update. And this is verified? It works if you ignore the docu and if you need to place a file somewhere xD

yringler commented 4 years ago

In general nativescript has never really caught on like other cross platform solutions. One symptom is that there aren't that many great plugins which are being actively worked on by an active community (read, zero). Although a fantastic product, and I enjoyed testing it out in a project, I've ultimately stopped using it, and switched to flutter, whose community is jaw droppingly active. There are a plethora of incredible plugins, with lots of active people behind them, sometimes doing mindblowing things. Performance is out of this world, and getting better. The biggest problem I had, when I was looking at a sql ORM (I don't need one yet, but will soon), is that there are a bunch of high quality, well supported options, with active communities behind them.

Flutter uses dart, not javascript. Some people consider that bad, but it hasn't kept flutter from taking off. Probably because dart is AWESOME! Personally, I think the whole concept of making sophisticated programs with html/javascript is really bad, and JS in particular is just a flat out terrible language, and I'd avoid it like the plague if I could. Yes, if you have to use JS, typescript is great, but ultimately the types are very shallow, they aren't enforced by the runtime.

andipahlevy commented 3 years ago

this "OkHttp Dispatcher" error shown when we are set up the fileName attribute.

triniwiz commented 3 years ago

This will be fixed in the next release , I'm currently working through my plugins list worked on ~3 randomly before deciding to do it alphabetically so currently on a. 😂

andipahlevy commented 3 years ago

This will be fixed in the next release , I'm currently working through my plugins list worked on ~3 randomly before deciding to do it alphabetically so currently on a. 😂

ok thanks bro. for now, i can handle it with rename method. Thanks for your hard work