QML download and save binary file

6982
6
Jump to solution
02-02-2016 06:55 AM
ZdenekJankovsky
New Contributor

Hello,

I am looking for the way how to download and save binary files (up to 1GB).

I found out that with direct QML is not possible to save the file. AppStudio has FileFolder class with writeFile function, but it seems that it writes only text files.

I got downloading working somehow, with QML XMLHttpRequest, but I think it is not usable for large files because you have to read the whole file in memory.

Does anybody use downloading and saving files in QML?

Thank in advanced,

Zdenek J.

0 Kudos
1 Solution

Accepted Solutions
StephenQuan1
Esri Contributor

Hello Zdenek J.,

The best component for this is the NetworkRequest object and setting the responseFile attribute. This will ensure that the file is downloaded directly to file whilst keeping a low memory footprint.

Stephen

View solution in original post

6 Replies
StephenQuan1
Esri Contributor

Hello Zdenek J.,

The best component for this is the NetworkRequest object and setting the responseFile attribute. This will ensure that the file is downloaded directly to file whilst keeping a low memory footprint.

Stephen

ZdenekJankovsky
New Contributor

Hi Stephen Quan​,

thank you for this reference, I wasn't able to find it on my own in the help/doc.

It is in ArcGIS.AppFramework. There is a Esri Sample using it as well: http://www.arcgis.com/home/item.html?id=bfb0dec97a254a0d9d609a3e3cc95598 - better to search it through AppStudio itself.

Thanks, I will give that a try.

Zdenek J.

0 Kudos
ZdenekJankovsky
New Contributor

Hi all,

I would like to have one more question: is there any chance to use NetworkRequest object to download files from secured web folder, e.g. HTTPS Basic Authentication?

Or I am not sure if it would be possible to upload our files (around 750MB each) to Portal and then downloaded from Portal with portal credentials in the play.

Thanks for comments on this.

Zdenek J.

0 Kudos
StephenQuan1
Esri Contributor

Hello Zdenek J.,

Sorry for the late response. HTTPS is subject to the SSL algorithms that your device is capable of.

Having said that, I would expect that every device supports HTTPS Basic Authentication.

The other thing to clarify is which HTTP method are you using to upload? HTTP GET? HTTP POST? Or something else? i.e. HTTP PUT?

Stephen

0 Kudos
ZdenekJankovsky
New Contributor

Hi,

thank you for clarification.

I see, I have written my last post quite confusing. Workflow with the app is this:

  1. SDE geodatabase with the data,
  2. generating offline *.geodatabase package with Python every week from main SDE (it is a file up to 1GB),
  3. now we try to solve how to get the new package of data to Android tablet:
    1. manualy copy the *.geodatabase to Android tablet (we use this now),
    2. upload the package to Portal (with Python) and let AppStudio to download it from portal? (Does AppStudio QML SDK have classes for browsing Portal items and dowload them?)
    3. copy the package to dedicated web server (with Python) and let AppStudio do download it from it? (HTTPS, Should at least Basic Authentication work with NetworkRequest object?)

Well I hope I put it on the right track.

Thanks,

Zdenek J.

0 Kudos
StephenQuan1
Esri Contributor

Hi Zdenek,

If you refer to the AppStudio Framework Runtime, there are a number of Portal objects that you can use to build to browse Portal Items:

- Portal

- PortalDownloadUserContent or PortalSearchItems

- PortalDownloadItemInfo

- PortalDownloadItemData

- When running Qt Creator, select Help and open AppStudio Framework Runtime

Alternatively, if you want to use the NetworkRequest object, you can directly access the REST API or connect to any web server to download the package. As your data is secured behind HTTPS, there are a number of HTTPS considerations when using the NetworkRequest object:

- Handle SSL certificate challenge correctly via onSslErrors / on sslErrorsIgnored signals and the ignoredSslErrors property

- If HTTPS is secured, supply credentials (i.e. username / password)

As to your specific Basic Authentication support question, that's really up to the SSL algorithms installed on your device. Basic Authentication, I would expect, to be universally available.

Stephen

0 Kudos