Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Mon Sep 21, 2020 12:59 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: upload/download file to website (Windows and OSX)
PostPosted: Sat Sep 04, 2010 4:04 pm 
Offline

Joined: Sat Oct 21, 2006 6:03 pm
Posts: 70
I've been trying to get cURL to work. Any other ideas? (Free is best).


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Sep 05, 2010 2:11 am 
Offline
User avatar

Joined: Fri Jun 05, 2009 11:50 am
Posts: 348
Location: Hamburg, Germany
so what have you tried so far?

_________________
Best regards

Stefan

Mac OSX Mountain Lion (latest Release) on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3


Last edited by elChupete on Wed Sep 14, 2011 4:43 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Sep 05, 2010 2:25 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
Did you try the CURLSMBS class from our Plugins?
Or was that curl on the command line?

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Sep 05, 2010 10:44 am 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
Somewhere on this forum I posted the syntax for just about every standard cURL function.

Its a piece of cake [at least under OSX] to call it from a script. And I use it all the time instead of complicated FTP classes..


No plugins required.

// to return a directory
curl -s -S -u <username>:<password> FTP://www.myserver.com"

// to download a file
curl -s -S -u <username>:<password> FTP://www.myserver.com -o "+chr(34)+"<remotefilename>"+chr(34)

// to upload a file
curl -s -S -u <username>:<password> FTP://www.myserver.com -T "+chr(34)+"<localfilename>"+chr(34)

// to Make a Directory
curl -s -S -u <username>:<password> FTP://www.myserver.com -Q 'MKD <newname>';

// to Remove a Directory
curl -s -S -u <username>:<password> FTP://www.myserver.com -Q 'RMD <dirname>';

// to Remove a File
curl -s -S -u <username>:<password> FTP://www.myserver.com -Q 'DELE <filename>';

// to Change File Permissons [UNIX ONLY]
curl -s -S -u <username>:<password> FTP://www.myserver.com -Q 'SITE CHMOD <permission> <filename>'"

// to Rename a File
curl -s -S -u <username>:<password> FTP://www.myserver.com -Q 'RNFR <oldname>'; -Q 'RNTO <newname>';

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 14, 2010 11:59 am 
Offline

Joined: Sat Oct 21, 2006 6:03 pm
Posts: 70
I've been trying Dave's suggestions, but to no avail.

Dave ... Is there more to it than the command line you suggest?


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 14, 2010 4:02 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
They have to be the EXACT correct syntax....
and issued via the SHELL command

give me an example of a command line you generated, and what error message you got

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 14, 2010 8:05 pm 
Offline

Joined: Sat Oct 21, 2006 6:03 pm
Posts: 70
No error message ... It just doesn't upload.

dim s as new shell
dim cmd, filename as string

s.Execute "dir"

filename = "BobTeams.rsd"

cmd = "curl -s -S -u **:** ftp://www.circleconsulting.us//public_html/teamfiles/" + filename + " -T "+ directory+filename

msgbox cmd

s.Execute cmd


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 14, 2010 8:58 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
The error message is in s.Result and/or s.ErrorCode


Here is the major parts of a simple FTP app I wrote to allow me to upload files directly to my webserver. Note ... for this app it uploads a file from a Directory structure into the SAME directory structure on the Server. This is NOT a requirement of CURL... it just made it easier for this little app.

SUB UPLOAD_FILE()

const username="myusername"
const password="mypassword"
const web_dir ="www.mywebsite.org/usr/local/apache2/htdocs/international/"
#if not DebugBuild
#pragma DisableBackgroundTasks
#pragma DisableBoundsChecking
#pragma DisableAutoWaitCursor
#endif
dim abort as boolean
dim x as integer
dim exit_now as boolean
Dim dlg As OpenDialog
dim src_file as folderitem
dim web_file as string
exit_now=false
while not exit_now
lbl_msg.TextColor=&c000000
abort=false
dlg=New OpenDialog
dlg.Title="Select File to Upload"
src_file=dlg.ShowModal()
abort=(src_file=nil)
exit_now=abort

if not abort then
web_file=NthField(src_file.ShellPath,"/",4)
x=instr(src_file.ShellPath,web_file)
web_file=web_dir+mid(src_file.ShellPath,x+len(web_file)+1)
//web_file=left(web_file,len(web_file)-len(src_file.DisplayName)-1)
if not src_file.exists then
beep
lbl_msg.TextColor=&cff0000
lbl_msg.text="Not Found : "+src_file.DisplayName
abort=true
end if
//
if not abort then
lbl_msg.text="Uploading "+src_file.DisplayName
app.DoEvents
//
curl_cmd="cURL -s -S -u "+username+":"+password+" FTP://"+lowercase(web_file)+" -T "+src_file.ShellPath
cURL_flag=cURL_Execute(cURL_cmd,cURL_result)
//
if curl_flag then
beep
msgbox str(curl_flag)+chr(13)+curl_result
lbl_msg.TextColor=&cff0000
lbl_msg.text="Failed : "+src_file.DisplayName
abort=true
else
lbl_msg.TextColor=&c007700
lbl_msg.text="Upload Complete"
end if
app.DoEvents
end if
end if
wend

END SUB


FUNCTION CURL_EXECUTE(cmd as string,byref retcode as string) as boolean

#if not DebugBuild
#pragma DisableBackgroundTasks
#pragma DisableBoundsChecking
#pragma DisableAutoWaitCursor
#endif
Dim sh As new shell
Dim failed As Boolean

app.DoEvents
failed=false
//
sh.Mode = 0
sh.Execute cmd
retcode=sh.Result
if (sh.ErrorCode<>0) then failed=true
retcode=ReplaceLineEndings(retcode,EndOfLine.UNIX)
'
' Check if Image Create Failed
'
if left(retcode,7)="cURL: (" then failed=true
return failed

END FUNCTION


// Module Level Variables

cURL_CMD as string
cURL_Flag as boolean
cURL_Result as string
Web_Dir as string


WIndow has ONE control.... lbl_msg as STATICTEXT

Note : depending on your webserver.... UPPER vs LOWER case in filenames MAY make a difference

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Sep 19, 2010 6:15 pm 
Offline

Joined: Mon Oct 29, 2007 10:30 pm
Posts: 302
Location: Argentina
You have double slash that is probably wrong before public_html:

cmd = "curl -s -S -u **:** ftp://www.circleconsulting.us//public_html/teamfiles/" + filename + " -T "+ directory+filename

_________________
Pablo Schwindt
RealBasic 2007R5
Windows 7 32bits
Mac OSX SL 10.6.4


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Dec 19, 2010 8:46 pm 
Offline

Joined: Sat Oct 21, 2006 6:03 pm
Posts: 70
my result is that cURL is not recognized as an internal or external command.

WINDOWS 7


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Dec 19, 2010 10:12 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
cURL is installed as part of OSX...
You have to find someplace to download a copy to work with Windows.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Sun Dec 19, 2010 10:48 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
I have a copy curl.exe in this archive of other utils ported from *nix: http://www.boredomsoft.org/hosted/tools.7z

_________________
Boredom Software


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Mon Dec 20, 2010 4:15 am 
Offline
User avatar

Joined: Wed May 10, 2006 2:42 pm
Posts: 2985
Location: Germany
I think the key was to use our CURLSMBS class as the CURL code is built into the plugin and you have less trouble and more options directly accessible.

Greetings
Christian

_________________
See you in Orlando, Florida for Real World 2013
More details and registration here:
http://www.realsoftware.com/community/realworld.php


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 13, 2011 7:45 pm 
Offline
User avatar

Joined: Sun Aug 05, 2007 10:46 am
Posts: 4931
Location: San Diego, CA
For any who are interested.... in a few days I will be posting a link to a RealStudio class object that I have develped that implements cURL under OSX.

It has functions to UPLOAD, DOWNLOAD, RENAME, DELETE, CHMOD, Make Directory, Delete Directory and Get a Directory and examine all the file information

this implements the OSX cURL utility via a shell.....

and can probably be modified to work with WIndows if cURL is installed.

_________________
Dave Sisemore
iMac I7[2012], OSX Mountain Lion 10.8.3 RB2012r2.1
Note : I am not interested in any solutions that involve custom Plug-ins of any kind


Top
 Profile  
Reply with quote  
 Post subject: Re: upload/download file to website (Windows and OSX)
PostPosted: Tue Sep 13, 2011 9:45 pm 
Offline
User avatar

Joined: Mon Apr 02, 2007 2:08 am
Posts: 1225
Location: San Francisco, CA, USA
I've been working on some libcurl classes for RB. If anyone wants it, here it is. Also, it sort of sucks, so suggestions/patches are welcome.

_________________
Boredom Software


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page 1, 2  Next

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group