network.download() used to download file from Google Drive or Dropbox is not working

Hello Guys,

I am trying to download a file from Google Drive and Dropbox.

  1. I upload my PNG file to Google Drive OR Dropbox 
  2. click share and create public download link
  3. Now I have public URL to download the file

I have used below code :

local function networkListener( event ) if ( event.isError ) then print( "Network error - download failed: ", event.response ) elseif ( event.phase == "began" ) then print( "Progress Phase: began" ) elseif ( event.phase == "ended" ) then print( "Displaying response image file" ) myImage = display.newImage( event.response.filename, event.response.baseDirectory, 60, 40 ) myImage.alpha = 0 transition.to( myImage, { alpha=1.0 } ) end end local params = {} params.progress = true network.download( "PUBLIC URL from Google Drive OR Dropbox", "GET", networkListener, params, "helloCopy.png", system.TemporaryDirectory )

– I can see a message in console that “helloCopy.png” is not a valid image file.

–> When I used this url : “http://docs.coronalabs.com/images/simulator/image-mask-base2.png
it’s working.

– I have tried same code to download a zip file also and then I tried to uncompress zip file manually on my Mac. (Error : unsupported file  screenshot)

Please help me regards this , what I can’t download files from google drive and dropbox public link ?

Thank you.
Bhavin

I haven’t done/used this myself, but here’s some info/code you may give a try.

https://forums.coronalabs.com/topic/73687-whats-the-easiest-cloud-solution-to-use/

https://gist.github.com/HoraceBury/dd46914c0449da7e14cb380dc05766aa

Hi @Michael Flad,

Thanks for your reply but.
I am working on the App which require to import zip file to import data.
So any user will upload zip file where it can be share for public (for example. Google Drive , Dropbox or any other)
To import I will download the file from the user provided : it can be google drive file public url or dropbox public link.

I know that if I download file from my server then it will work , but I can’t be sure where user will upload the file.
Why file formate becomes unsupported after download from Google Drive or dropbox ?

Thanks again.

 

I think I understand the issue with Dropbox and Google Drive.

I am not sure but I think the public link will return the HTML page that show’s download option there (you can check dropbox public link in your browser and see what it shows on the page) , So definitely this is not our file in the public link response.

is there any website that provide direct download link ?

See if that helps you …

https://zapier.com/learn/how-to/generate-direct-dropbox-link/