libURL and New TsNet Commands/Failures

Sannyasin Brahmanathaswami brahma at hindu.org
Mon Aug 1 01:43:25 EDT 2016


@ jacque: It's my understanding that you need to buy the business edition if you want asynchronous connections, even if you are a developer of one.. perhaps I am wrong.

@ Charles: thanks for the debug stack.. very useful.  But we have a problem, possible but or need more documention on the "how to…"

I'm getting an "invalid url" from libURL on my test attempts to upload a whole folder

Note that I'm mixing in a 

tsNetCreateMissingDirs "true"  # command

because the folders we want to push do not exist. 

Use case here is the default WordPress blog/wp-content/uploads folder..and the tool I'm working on will allow bloggers to upload folders of images, the stack then does remote xml/rpc to WP to add a post to the blog… … 

so far my test stack is working for fetching listings and uploading single files using simple "put"  and no explicit libURL* commands… so far so good… but put loads the data into memory first. better to use libURL to read the bin file directly  and upload..

 I presumed one must loop through files in a folder to upload a folder as there is no "upload folder" in the dictionary…. 

# set up 
function initializeConnectionDetails
   tsNetCreateMissingDirs "true"
   libURLSetFTPListCommand "NLST"
   put fld "UserName" into sUserName
   put fld "PassWord" into sPassword
   put fld "HostDomain" into sHostDomain
   put fld "RemoteRootPath" into sRemoteRootPath
  return ("sftp://" & sUserName & ":" & sPassword & "@" & sHostDomain & sRemoteRootPath & "/")
end initializeConnectionDetails

# my test is to prompt for a folder and then upload all the files therein to a new folder on the server, the name of which we create on the fly here (name is not based on the source folder on the local machine)

on mouseUp
   put initializeConnectionDetails() into tStem
   put fld "remoteTarget" after tStem
   answer folder "Choose a folder to upload"
   put it into tSourceFolder
   put files (tSourceFolder) into tFilesToUpload # yay no more default folder required!

   repeat for each line x in tFilesToUpload
      libURLftpUploadFile ("binfile:"& tSourceFolder &"/"& x),(tStem &  "testUploads/" & x)
      put the result & cr after tResult
   end repeat
   put tResult
end mouseUp

I get  

invalid url
invalid url
invalid url  etc.. in my result 

where the explicit command(s) being issued in the repeat loop would look like this:

libURLftpUploadFile \
# local path to file to be uploaded:
binfile:/Users/Brahmanathaswami/Documents/App-Development/SivaSivaAppWorking/Coloring module Resources/GIF images (no background)/Standing Ganesha GIF.gif,
# remote path to upload to:
sftp://user:password@our.hostdomain.com/home/user/public_html/blog/wp-content/uploads/2016/07/testUploads/Standing%20Ganesha%20GIF.gif

Hmm what is going on, I thought? So I tried using libURLftpUpload for the single file that I was doing successfully with "put"

like this:

on mouseUp
   put initializeConnectionDetails() into tRemoteDir
   put fld "remoteTarget" after tRemoteDir
   answer file "Choose a file to upload"
   put it into tFilePath
   set the itemDel to "/"
   put item -1 of tFilePath into tFilename
   replace space with "_" in tFileName
   --put url ("binfile:" & it) into tData
   --put tData into url( tStem & tFileName)
   libURLftpUploadFile  tData, (tRemoteDir & tFileName)
   put the result
end mouseUp

this also returned "invalid url"

in the above, we know the URL's are good, because, it works with "put" 

OK so the filename had spaces so I added this:

put urlEncode(tFileName) into tFileName

still get "invalid URL

So why not with libURLftpUploadFile?

Is it because libURLftpUploadFile  does not understand SFTP?

What am I missing?

BR


On 7/31/16, 7:07 PM, "use-livecode on behalf of Charles Warwick" <use-livecode-bounces at lists.runrev.com on behalf of charles at techstrategies.com.au> wrote:

    >place that works most of the time, but not having the problem at all 
    >would be a big plus. I think asyncronous transactions and the much 
    >faster tsNet external may solve that.
    >
    Sounds like a perfect job for asynchronous connections or the Business 
    edition :-)



More information about the use-livecode mailing list