network.download

Thanks a lot Tom!
You’re right!
Now is working.
[import]uid: 44013 topic_id: 24298 reply_id: 144253[/import]

This is how I try:

local docs\_path = system.pathForFile( "", system.DocumentsDirectory )  
   
-- change current working directory  
local success = lfs.chdir( docs\_path )  
local new\_folder\_path  
local dname = "proba"  
if success then  
 lfs.mkdir( dname )  
 new\_folder\_path = lfs.currentdir() .. "/" .. dname .. "/"  
end  
   
...  
   
local destino = system.pathForFile("",system.DocumentsDirectory)  
lfs.chdir(destino)  
local dest = destino.."/proba/"  
   
network.download( origin, "GET", arqDescargado, arquivo, dest )  
   
...  
   

The files are downloaded to DocumentsDirectory instead of DocumentsDirectory/proba

What am I doing wrong? [import]uid: 44013 topic_id: 24298 reply_id: 144157[/import]

The problem with your code example is “dest” is defined as “baseDir”, which is a file directory constant and should not be appended with your subfolder name. The subfolder should be appended to the file name instead
[lua]network.download( origin, “GET”, arqDescargado, “/proba/” … arquivo, system.DocumentsDirectory )[/lua] [import]uid: 7559 topic_id: 24298 reply_id: 144188[/import]

Thanks a lot Tom!
You’re right!
Now is working.
[import]uid: 44013 topic_id: 24298 reply_id: 144253[/import]

I’m in the same case as team1:
“I have created a sub directory in system.DocumentsDirectory and i want to download graphics directly into the sub directory i created. right now when i try and feed it a path other than system base directories, it ignors them and reverts to the default of system.DocumentsDirectory”

As Tom said, I’ve tryed to add the subdirectory name to the destFile parameter, but the files are saved out of this subfolder.

What am I doing wrong?

Alberto. [import]uid: 44013 topic_id: 24298 reply_id: 143201[/import]

This is how I try:

local docs\_path = system.pathForFile( "", system.DocumentsDirectory )  
   
-- change current working directory  
local success = lfs.chdir( docs\_path )  
local new\_folder\_path  
local dname = "proba"  
if success then  
 lfs.mkdir( dname )  
 new\_folder\_path = lfs.currentdir() .. "/" .. dname .. "/"  
end  
   
...  
   
local destino = system.pathForFile("",system.DocumentsDirectory)  
lfs.chdir(destino)  
local dest = destino.."/proba/"  
   
network.download( origin, "GET", arqDescargado, arquivo, dest )  
   
...  
   

The files are downloaded to DocumentsDirectory instead of DocumentsDirectory/proba

What am I doing wrong? [import]uid: 44013 topic_id: 24298 reply_id: 144157[/import]

I’m in the same case as team1:
“I have created a sub directory in system.DocumentsDirectory and i want to download graphics directly into the sub directory i created. right now when i try and feed it a path other than system base directories, it ignors them and reverts to the default of system.DocumentsDirectory”

As Tom said, I’ve tryed to add the subdirectory name to the destFile parameter, but the files are saved out of this subfolder.

What am I doing wrong?

Alberto. [import]uid: 44013 topic_id: 24298 reply_id: 143201[/import]

The problem with your code example is “dest” is defined as “baseDir”, which is a file directory constant and should not be appended with your subfolder name. The subfolder should be appended to the file name instead
[lua]network.download( origin, “GET”, arqDescargado, “/proba/” … arquivo, system.DocumentsDirectory )[/lua] [import]uid: 7559 topic_id: 24298 reply_id: 144188[/import]

Thanks a lot Tom!
You’re right!
Now is working.
[import]uid: 44013 topic_id: 24298 reply_id: 144253[/import]

This is how I try:

local docs\_path = system.pathForFile( "", system.DocumentsDirectory )  
   
-- change current working directory  
local success = lfs.chdir( docs\_path )  
local new\_folder\_path  
local dname = "proba"  
if success then  
 lfs.mkdir( dname )  
 new\_folder\_path = lfs.currentdir() .. "/" .. dname .. "/"  
end  
   
...  
   
local destino = system.pathForFile("",system.DocumentsDirectory)  
lfs.chdir(destino)  
local dest = destino.."/proba/"  
   
network.download( origin, "GET", arqDescargado, arquivo, dest )  
   
...  
   

The files are downloaded to DocumentsDirectory instead of DocumentsDirectory/proba

What am I doing wrong? [import]uid: 44013 topic_id: 24298 reply_id: 144157[/import]

The problem with your code example is “dest” is defined as “baseDir”, which is a file directory constant and should not be appended with your subfolder name. The subfolder should be appended to the file name instead
[lua]network.download( origin, “GET”, arqDescargado, “/proba/” … arquivo, system.DocumentsDirectory )[/lua] [import]uid: 7559 topic_id: 24298 reply_id: 144188[/import]

Thanks a lot Tom!
You’re right!
Now is working.
[import]uid: 44013 topic_id: 24298 reply_id: 144253[/import]

Dear Corona Team ,
we still need way to re-save files that we laoded via network.download

What wrong: network.download cant change file. If i`m trying to re-download file to same destination I just got event.isError=true. While I was hoping Corona whould just re-save it.

Why I need it: Corona creating empty file first, then downloading it. If it get interupted during procces, or file downloaded as corrupted - i`m f*cked. It have size 0, but now i cant do thing about it - since this method CANT change file that was created.

Current State: network.download is NOT WORKING 100%. It does work, but it desinged to fail at some point.

Docs : It again missleading : New page dosent have info about responces and list of errors. Old page does, but it not full - there is nothing about that isError=true goes for network fail AND for saving file fail.

How to fix it:

  • Dont create file before it have been finished downloading. Use temp dir for temp files and data.
  • Re-save file if it was re-downloaded.
  • Update new docs with Errors list and responces info. [import]uid: 90911 topic_id: 24298 reply_id: 145552[/import]

@efgames, file a bug report stating the problem and how to reproduce it. As for the docs, go to the Daily Build Doc pages and on the network.download page, click “I Hate It” at the bottom of the page and list the problems. That will be filed as a bug report against the docs.

Stating the issue in the forums is fine but doesn’t get it fixed.

Thanks. [import]uid: 7559 topic_id: 24298 reply_id: 145561[/import]

Hey Tom,
I did it already. Since here this bug mentioned 3 times =) [import]uid: 90911 topic_id: 24298 reply_id: 145573[/import]

Dear Corona Team ,
we still need way to re-save files that we laoded via network.download

What wrong: network.download cant change file. If i`m trying to re-download file to same destination I just got event.isError=true. While I was hoping Corona whould just re-save it.

Why I need it: Corona creating empty file first, then downloading it. If it get interupted during procces, or file downloaded as corrupted - i`m f*cked. It have size 0, but now i cant do thing about it - since this method CANT change file that was created.

Current State: network.download is NOT WORKING 100%. It does work, but it desinged to fail at some point.

Docs : It again missleading : New page dosent have info about responces and list of errors. Old page does, but it not full - there is nothing about that isError=true goes for network fail AND for saving file fail.

How to fix it:

  • Dont create file before it have been finished downloading. Use temp dir for temp files and data.
  • Re-save file if it was re-downloaded.
  • Update new docs with Errors list and responces info. [import]uid: 90911 topic_id: 24298 reply_id: 145552[/import]

@efgames, file a bug report stating the problem and how to reproduce it. As for the docs, go to the Daily Build Doc pages and on the network.download page, click “I Hate It” at the bottom of the page and list the problems. That will be filed as a bug report against the docs.

Stating the issue in the forums is fine but doesn’t get it fixed.

Thanks. [import]uid: 7559 topic_id: 24298 reply_id: 145561[/import]

Hey Tom,
I did it already. Since here this bug mentioned 3 times =) [import]uid: 90911 topic_id: 24298 reply_id: 145573[/import]