Forums

OverviewFelgo 2 Support (Qt 5) › download files to android

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23530

    jrrobles79

    Do I have to do something special to download files on Android?  I have already added the permissions to write on the device, and added almost the same code that the example on https://felgo.com/doc/felgo-downloadableresource/#open-downloaded-files

     

    I have the same code as the example just added some console.log:

    DownloadableResource {
               id: downloadableResource
               source: "https://www.dropbox.com/s/6radnxx1myevrpn/some_file.pdf"
               storageLocation: FileUtils.DownloadLocation
               storageName: "somefile_3.pdf"
               extractAsPackage: info.info_content.endsWith(".zip")
               onDownloadFinished: {
    
                   switch(error){
    
                    case  DownloadableResource.NetworkError:
                         console.debug("DownloadableResource: Network error");
                        break;
    
                    case  DownloadableResource.UnauthorizedError:
                        console.debug("DownloadableResource: Unauthorized Error");
                        break;
                    case  DownloadableResource.FilePathError:
                        console.debug("DownloadableResource: file path Error");
                        break;
                    case  DownloadableResource.FileExtractionError:
                        console.debug("DownloadableResource: File Extraction Error");
                        break;
                     case  DownloadableResource.DownloadCancelledError:
                         console.debug("DownloadableResource: Downloa dCancelled Error");
                         break;
                     case DownloadableResource.UnknownError :
                         console.debug("DownloadableResource: UnknownError");
                         break;
    
                     case DownloadableResource.NoError:
                     default:
                         console.debug("DownloadableResource: No error")
                         break;
                   }
    
               }
    
               Component.onCompleted: {
                   console.debug( "getting file:" + info.url )
    
                if(downloadableResource.status === DownloadableResource.UnAvailable) {
                     console.debug("resurce unavailable, download...")
                   downloadableResource.download()
                 } else {
                     console.debug("resurce available...")
                   openDownloadedFile()
                 }
               }
    
               onStatusChanged: {
    
                   switch(status){
                    case  DownloadableResource.UnAvailable:
                         console.debug( "Resource: UnAvailable");
                        break;
                    case  DownloadableResource.Available:
                        console.debug("Resource:  Available");
                        openDownloadedFile()
                        break;
                    case  DownloadableResource.Downloading:
                        console.debug("Resource:  Downloading");
                        break;
                     case  DownloadableResource.Extracting:
                         console.debug("Resource:  Extracting");
                         break;
                     default:
                         console.debug("No error")
                         break;
                   }
    
               }
    
               function openDownloadedFile() {
                   console.debug("opening file:" + downloadableResource.storagePath)
                 if(downloadableResource.status === DownloadableResource.Available) {
                   fileUtils.openFile(downloadableResource.storagePath )
                 }
               }
             }

     

    but when fileUtils,openFile is trigger it hust fkash the pdf reader and hides immediate, also I go to the device and search for the file and can’t find it on my downloads folder, or other folder, is like it didn’t downloaded but the DownloadResource.status said the file is available, what Im missing?      

     

    PD: I modified the pdf path since I was using a manual for an old client, and can’t publish that here

    #23532

    jrrobles79

    ===SOLVED (in part)===

    I found where the files are being stored, but I still have some issues, so  I will open a new Thread.

     

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support