Create new folder with ftp url

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Create new folder with ftp url

Post by doobox » Sat Jul 16, 2011 2:01 pm

Hi there,

I find this one pretty strange. I know ios is more limited than the desktop re: FTP.
But cant understand why the desktop will automatically create a folder on the server if none exists but ios wont.

This works on desktop but not on ios.. note the inclusion of the folder Airweaver, that does not already exist on the server:

Code: Select all

on mouseUp
   put"ftp://username:"& URLEncode(password) & "@ftp.doobox.co.uk/public_html/Airweaver/"&gSelectedStackCode&".png" into tURL
   put image "imageholder" into URL tURL
end mouseUp
This works on ios, posting directly to the root.. but that really is no good to me:

Code: Select all

   put"ftp://username:"& URLEncode(password) & "@ftp.doobox.co.uk/public_html/"&gSelectedStackCode&".png" into tURL
   put image "imageholder" into URL tURL
Can i get ios to create a folder on the server or not..?
Kind Regards
Gary

https://www.doobox.co.uk

SparkOut
Posts: 2947
Joined: Sun Sep 23, 2007 4:58 pm

Re: Create new folder with ftp url

Post by SparkOut » Sat Jul 16, 2011 3:24 pm

I don't know if you can use the libURL library on iOS? I don't think it was possible before but is it something that has been introduced? Anyway, if you have access to the libURLftpCommand you can test for the existence of a folder and make one if it does not exist already. Pass a path to verify to the confirmFTPpath command and it will take each folder in turn and use the CWD (change working directory) try to change the server working directory to that folder. If successful it will continue with the next folder in the path, if a code 550 is received then the directory change was not successful because the desired folder did not exist, so it attempts to make one using MKD (make directory). If a MKD attempt returns a code of 257 then it was successful (at least on my testing here!) so execution will continue with any further directories required, or if the folder could not be created (maybe trying to write to an area without permissions) it should stop with an error message.

If iOS still has no access to the libURL library, then I'm afraid I don't know how you should proceed.

Code: Select all

command confirmFTPpath pPath
   set the itemDelimiter to "/"
   repeat for each item tItem in pPath
      if tItem is not empty then
         put "/" & tItem after tCheckPath
         checkPath tCheckPath
      end if
   end repeat
end confirmFTPpath

command checkPath pCheckPath
   put "CWD" && pCheckPath into tCommand
   put libURLftpCommand (tCommand,"hostname","username","password") into tResult
   if tResult begins with 550 then
      makePath pCheckPath
   end if   
end checkPath

command makePath pMakePath
   put "MKD" && pMakePath into tCommand
   put libURLftpCommand (tCommand,"hostname","username","password") into tResult
   if not (tResult begins with 257) then
      answer error "Cannot create path" && pMakePath
      exit to top
   end if 
end makePath

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Create new folder with ftp url

Post by doobox » Sat Jul 16, 2011 3:35 pm

Thank you,

i think ios only supports Added support for 'libUrlDownloadToFile' at the moment.

It turns out that i can do a workaround like this:

In a separate operation before trying to upload the file to the folder that does not exist, i can
create that folder i want on the server, like this:

Code: Select all

 put"ftp://username:"& URLEncode(password) & "@ftp.doobox.co.uk/public_html/Airweaver/" into tURL
   put "any old rubbish here" into URL tURL
In my case i can do this when the user enters there ftp details, and saves.
Way before they will be uploading a file to that folder.

I guess i still need to check for the existence of the folder.
But i think i should be able to handle that in the callback from creating the folder in the first place.
If it does not return "uploaded" then i will make them try again before they can go any further in the app.

It still strikes me a a little strange that i can create a folder using ios in one operation.
Or create a file in one operation.
But i cant create a folder and a file in the same operation.
Kind Regards
Gary

https://www.doobox.co.uk

bertBUSIbr8
Posts: 38
Joined: Thu Jun 28, 2012 2:48 pm
Contact:

Re: Create new folder with ftp url

Post by bertBUSIbr8 » Tue Nov 19, 2013 11:47 am

Hi,


Having the same problem here at the moment but on Android.

I'm creating folders on the Android device to store files in [photo's taken with the device here].

I would need to upload these folders to a local ftp, not just the contents, but actually creating the folders on the ftp as they are created on the fly on the device during usage.

FTP'ing the individual files to the ftp work fine, but I can not create the folders. [I can create them from the desktop however, just not from the mobile device].

Does anyone has some advice here?


Many thanks,


Bert

Post Reply