How to create QtObject inside a javascript file

416
2
03-19-2021 06:02 AM
x_d
by
New Contributor III

Hi, there so i tried this example to download a image from server and save it to the local. This Works fine on laptop. But test the same thing on my phone it doesn't save the photo to the path I given. What to do? can anybody please help.

 

 

 

Page{
    id: app

FileFolder { 
    id: fileFolder
    url: "assets/media_images"
}

//Downloads an image from the web
NetworkRequest {
    id: networkRequest
    url: "http://appstudio.arcgis.com/images/index/introview.jpg"
    responsePath: fileFolder.path +"/appstudio.jpg"

    property url imagePath: responsePath

   onReadyStateChanged: {
        if (readyState == NetworkRequest.DONE) {
        image.source = "assets/media_images"+"/appstudio.jpg";
       }
    }
    onError: {
        console.log(errorText + ", " + errorCode)
        //On failure, don't use the local copy
        image.source = ""
    }
}

ColumnLayout {
    spacing: 20
    Button {
        id:download
        text: "Download Request (Download Image)"
        Layout.margins: 2
        Layout.fillWidth: true
        onClicked: {
            networkRequest.send({f:"json"});
        }
    }

    Image {
        id: image
        Layout.margins: 10
        Layout.preferredWidth: 250
        Layout.preferredHeight: 200
    }
}
}

 

 

 

Tags (2)
0 Kudos
2 Replies
ErwinSoekianto
Esri Regular Contributor

@x_d 

 

Can you try changing the FileFolder section of the code? 

 

FileInfo {
        id: destData
        path: "~" 
    }

 

I think it is related of this change, https://community.esri.com/t5/arcgis-appstudio-blog/appstudio-and-android-10-scoped-storage-changes/...

 

Thank you,

Erwin

0 Kudos
x_d
by
New Contributor III

@ErwinSoekianto  Thanks for the reply. So I gone through the documentation the scoped storage changes. and applied the path as mentioned there. But still it's not working the image gets disappeared. On appstudio player it's working fine but when i made a build for testing then it gets disappeared 

0 Kudos