HTTPSocket Get URL As FolderItem on XojoCloud

Hello Xojo Community,

I am attempting to get a .pdf via url and save the file as a folderitem in the Shared_Documents directory on my Xojo Cloud account.

The file creates with correct name on Xojo Cloud, however byte size is 0 (i.e. no content)

I’m not sure what I have missed in my code below?

// get .pdf proposal file from remote server, save to Xojo Cloud > Shared_Documents. 
// Note: Xojo Cloud (available SpecialFolders are: Fonts,SharedDocuments,Documents,Temporary)

Dim tSocket As New HTTPSocket
Dim tProposalId As String = "123456789" // example string, usually a variable
Dim tDocName As String  = tProposalId + ".pdf"
Dim tFolderItem As FolderItem = SpecialFolder.SharedDocuments.Child(tDocName)
tSocket.Get("" +tDocName,tFolderItem)

Please advise. Kind regards, Andrew

You’re using an asynchronous Get, but a local variable which means that tSocket is going out of scope before the socket has a chance to download.

Either make tSocket a property of the page or add the third property to the Get command to indicate the Timeout. If doing the latter, I also suggest you set its Yield property to True.

Thank you for your swift reply Greg. My apologies, I overlooked the timeout (thought I had included it). Coding when tired (always a recipe for disaster…smiling). Thanks Greg.