SimonSimCity / Xamarin-CrossDownloadManager

A cross platform download manager for Xamarin
MIT License
149 stars 68 forks source link

Open downloaded file inside the application #93

Closed hashimks closed 6 years ago

hashimks commented 6 years ago

Hello @SimonSimCity

I am using the plugin for downloading files from the provided url. I am able to do it, however can you please help me opening and viewing the file simultaneously after the download?

SimonSimCity commented 6 years ago

Nice to get some feedback again 😄

In the sample project you can see how to get the URI after a successful download. From there on it's on your side what to do with the file.

I saw that I haven't included any sample on iOS which would return the path. Since I've moved over to other projects I'm not that experienced in Xamarin anymore ... Please ping me if you are struggling with it and I'll see when I have time to get a sample ready.

TomONeill commented 6 years ago

It would actually be easier if IDownload included a local file url (which gets set on PathNameForDownloadedFile). This way we can use other plugins, like https://github.com/Studyxnet/FilePicker-Plugin-for-Xamarin-and-Windows to open the file easily.

Edit: You can actually call PathNameForDownloadedFile with the IDownload to get the file location IF you choose to overwrite files with the same name. I included some logic to rename the file to have a unique name so I get another file location calling it. But it might work for you, if you allow overwriting files.

tvandegraaf commented 6 years ago

I created a PR that adds a property to the IDownloadFile object. This way you don't have to do obscure things like this: https://github.com/SimonSimCity/Xamarin-CrossDownloadManager/blob/develop/Sample/Droid/MainActivity.cs#L109

Unfortunately you can't use FilePicker-Plugin-for-Xamarin-and-Windows to open the file using that property, since it has an issue.

SimonSimCity commented 6 years ago

The PR #94 now got accepted and I've just published version 1.4.0 to nuget. This should now allow you to easily get the file destination by the property DestinationPathName of every IDownloadFile after they reached the status COMPLETED.

SimonSimCity commented 6 years ago

The PR should've made it much easier. Please report again on this ticket if you're still struggling and I'll reopen it.