← Back to team overview

ubuntu-phone team mailing list archive

Re: How can I get hold of the downloaded pic by using the SingleDownload API?

 

Thanks! I finally figured it out by having the following code:

        ListModel {

            id: mymodel

        }


        DownloadManager {

            id: manager


            onDownloadsChanged: {

                console.log("something is changed!");

                var length = downloads.length;


                console.log("length: " + length);


                for (var i = 0; i < length; i ++ ) {

                    downloads[i].finished.connect(onFinished);

                }


                function onFinished(path) {

                    console.log("path: " + path);

                    mymodel.append( {"filename" : path })

                }

            }

        }


The whole project code is at: git clone
https://gitcafe.com/ubuntu/downloadmanager.git



Cheers!

On Tue, May 5, 2015 at 3:22 PM, XiaoGuo Liu <xiaoguo.liu@xxxxxxxxxxxxx>
wrote:

> If I use download manager at
> https://developer.ubuntu.com/api/qml/sdk-14.10/Ubuntu.DownloadManager.DownloadManager/
>
> After the file is successfully downloaded, how can I get hold of the path
> of the downloaded file?
>
> Thanks & best regards,
> XiaoGuo
>
> On Mon, May 4, 2015 at 9:38 PM, Robert Schroll <rschroll@xxxxxxxxx> wrote:
>
>> On Mon, May 4, 2015 at 3:18 AM, XiaoGuo Liu <xiaoguo.liu@xxxxxxxxxxxxx>
>> wrote:
>>
>>> After I have downloaded the picture, the pic resides in the download
>>> managers private directory, and I cannot make use of it in my application
>>> due to the security confinement. May I know how get I get the picture and
>>> use it?
>>>
>>
>> When I test it, I get a the download to
>> ~/.local/share/ubuntu-download-manager/singledownload.ubuntu/Downloads/,
>> which is readable for the app. You can either use the file from that
>> location or copy it somewhere else.  (Copying the file will require a C++
>> plugin, as far as I know.)
>>
>> It used to be that apparmor didn't allow access to this directory, but
>> that was fixed six months ago.  See LP#1384349.  If you're seeing apparmor
>> denials for this directory in a current image, you should probably file
>> another bug against apparmor-easyprof-ubuntu.
>>
>> Robert
>>
>>
>>
>>
>
>
> --
> XiaoGuo, Liu (刘晓国)
> Mobile: +86-13911181302
>



-- 
XiaoGuo, Liu (刘晓国)
Mobile: +86-13911181302

Attachment: a.png
Description: PNG image


References