Another issue on FTP upload
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
Another issue on FTP upload
It all works fine from on campus, but doesn't work from outside, (even with VPN on).
FTP upload works with DreamWeaver using the same settings.
Is there a way to handle 'Secure FTP' settings in the Revolution upload?
FTP upload works with DreamWeaver using the same settings.
Is there a way to handle 'Secure FTP' settings in the Revolution upload?
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
I'm afraid not - there is no support for secure ftp connection in the libURL library that ships with rev. However, you can use the curl command-line tool from a shell call.
HTH,
Jan Schenkel.
HTH,
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
I'll Check that out.
Thanks, that looks interesting.
I have a CGI resource on that server- is it possible to have Revolution access that for uploads?
This is the link in the web page version:
It then prompts for the user name and file name.
Thanks again,
I have a CGI resource on that server- is it possible to have Revolution access that for uploads?
This is the link in the web page version:
Code: Select all
"http://MyServer.edu/cgi-bin/homework_upload.cgi" method="post" enctype="multipart/form-data">
Thanks again,
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
You sure can talk to the cgi on your server: take a look at the dictionary entries for the post command as well as the libUrlFormData and libUrlMultiPartFormAddData functions.
Jan Schenkel.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
I tried
OK, I'm trying that.
This is the script I used:
The variables match the fields in the web-based form.
This has the same components as a CGI on the server that I access successfully from a web page. I am trying to replicate it in Revolution. I'm using the same fields & content as in the web version but nothing happens.
See any problems?
How can I have the error feedback displayed after trying to submit?
This is the script I used:
The variables match the fields in the web-based form.
Code: Select all
local course, firstname, lastname, uploaded_file
put "MyCourse" into course
put "MyFirst" into firstname
put "MyLast" into lastname
Put "/Users/MySection/*My Files Oct 2000/Student & Personnel/Sally/StudCreat_MaryTurk/1257535622.png" into uploaded_file
put libUrlFormData( course, firstname, lastname, uploaded_file) into tDataToPost
post tDataToPost to url "http://myserver.edu/cgi-bin/homework_upload.cgi"
See any problems?
How can I have the error feedback displayed after trying to submit?
Put a (scrolling) field on your card and call it "LogField" and then in the script before posting the data add(You have to use this odd syntax to refer to the field by name. See the notes in the dictionary.)
That will display all the output from the server so you can see what's going on.
It looks like that you need to use libUrlMultiPartFormAddData to build your data to post as one boundary-delimited parameter, rather than the name=value pairs you get with libUrlFormData.
Other than that, I always find that I have to wrap the url in parentheses (whether or not there is any evaluation to be done or just a quoted literal).
If you use the LiveHTTPHeaders addon for Firefox, you can view the web page and see the live exchanges between browser and server, and possibly find what you need to do to get successful replication in your RunRev application. It may be that a session cookie is set by the web page when you visit, for instance, and that cookie must be submitted with the post in order to be accepted. You can scan the header data in the Firefox addon and see what you need to extract. In RunRev, you would (perhaps - if this is the requirement!) first get the url and then parse the libURLLastRHHeaders () returned for the cookie data. Then you would "set the HTTPheaders to" values which include the required cookie information. When you then post the form data, RunRev will send the headers with that cookie data included and it will mimic the action of the browser. However, that's not necessarily required here, usually that sort of thing is to keep an authenticated session alive after username and password data has been submitted, but it seems you have to submit this at the same time as the upload file?
Code: Select all
libURLSetLogField the name of field "LogField"
That will display all the output from the server so you can see what's going on.
It looks like that you need to use libUrlMultiPartFormAddData to build your data to post as one boundary-delimited parameter, rather than the name=value pairs you get with libUrlFormData.
Other than that, I always find that I have to wrap the url in parentheses (whether or not there is any evaluation to be done or just a quoted literal).
If you use the LiveHTTPHeaders addon for Firefox, you can view the web page and see the live exchanges between browser and server, and possibly find what you need to do to get successful replication in your RunRev application. It may be that a session cookie is set by the web page when you visit, for instance, and that cookie must be submitted with the post in order to be accepted. You can scan the header data in the Firefox addon and see what you need to extract. In RunRev, you would (perhaps - if this is the requirement!) first get the url and then parse the libURLLastRHHeaders () returned for the cookie data. Then you would "set the HTTPheaders to" values which include the required cookie information. When you then post the form data, RunRev will send the headers with that cookie data included and it will mimic the action of the browser. However, that's not necessarily required here, usually that sort of thing is to keep an authenticated session alive after username and password data has been submitted, but it seems you have to submit this at the same time as the upload file?
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
Tried this
OK, I tried this code adapted from the dictionary:
This appears in the LogField:
socket selected: xxx.xx.xxx.xx:80|6964
POST /cgi-bin/homework_upload.cgi HTTP/1.1
Host: edtcserver.coe.tamu.edu
User-Agent: Revolution (MacOS)
Content-Length: 524
Content-type: multipart/form-data; boundary="__Part__cafyb2ys89dloes3kdvcxzsly"
HTTP/1.1 200 OK
Date: Wed, 11 Nov 2009 19:24:59 GMT
Server: Apache/1.3.33 (Darwin) mod_jk/1.2.2 PHP/4.4.1 DAV/1.0.3
Cache-Control: max-age=60
Expires: Wed, 11 Nov 2009 19:25:59 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
CLOSED xxx.xx.xxx.xx:80|6964
CLOSED xxx.xx.xxx.xx:80|6964
The put tForm statement produces this in the message box:
Content-type: multipart/form-data; boundary="__Part__4r1vvu74gmlute1h7jfpttm2x"
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="course"
MyCourse
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="firstname"
MyFirst
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="lastname"
MyLast
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="uploaded_file"
/Users/MyLogon/*My Files Oct 2000/Student/Fred/StudCreat_MaryTurk/1257535622.png
--__Part__4r1vvu74gmlute1h7jfpttm2x--
Which looks a lot like the Live HTTP Headers output:
http://edtcserver.coe.tamu.edu/cgi-bin/ ... upload.cgi
POST /cgi-bin/homework_upload.cgi HTTP/1.1
Host: server.edu
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://course.edu/Assignment-upload.html
Cookie: __utma=194481448.1246678664413041000.1242329551.1251401822.1253308902.7; __utmz=194481448.1251401822.6.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=employment%20TAMU; __utma=11651424.1159679486.1252518479.1252518479.1253297848.2; __utmz=11651424.1252518479.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Content-Type: multipart/form-data; boundary=---------------------------6475719317474173692004848058
Content-Length: 30978
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="course"
MyCourse
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="firstname"
MyFirst
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="lastname"
MyLast
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="uploaded_file"; filename="1257535622.png"
Content-Type: image/jpeg
ˇÿˇ‡
HTTP/1.x 200 OK
Date: Wed, 11 Nov 2009 19:36:54 GMT
Server: Apache/1.3.33 (Darwin) mod_jk/1.2.2 PHP/4.4.1 DAV/1.0.3
Cache-Control: max-age=60
Expires: Wed, 11 Nov 2009 19:37:54 GMT
Keep-Alive: timeout=15, max=500
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
I edited the paths & names to obscure the real information.
Not sure what else to try.
Thought it might be a problem because it is a graphics file but it didn't work with a text file either.
Code: Select all
local tCourse, tFirstname, tLastname,tUploaded_file
put "MyCourse" into tCourse
put "MyFirst" into tFirstname
put "MyLast" into tLastname
Put "binfile:"&"/Users/myLogon/My Files/Students/Fred/StudCreat_MaryTurk/1257535622.png" into tUploaded_file
put empty into tForm
put "http://edtcserver.coe.tamu.edu/cgi-bin/homework_upload.cgi" into tUrl
if libUrlMultipartFormData (tForm, "course", tCourse, "firstname", tFirstname, "lastname", tLastname, "uploaded_file", tUploaded_file) is not empty then
answer it ##error
else
set the httpHeaders to line 1 of tForm
put tForm
post line 2 to -1 of tForm to url tUrl
## check the result, etc., here
set the httpHeaders to empty
end if
libURLSetLogField the name of field "LogField"
This appears in the LogField:
socket selected: xxx.xx.xxx.xx:80|6964
POST /cgi-bin/homework_upload.cgi HTTP/1.1
Host: edtcserver.coe.tamu.edu
User-Agent: Revolution (MacOS)
Content-Length: 524
Content-type: multipart/form-data; boundary="__Part__cafyb2ys89dloes3kdvcxzsly"
HTTP/1.1 200 OK
Date: Wed, 11 Nov 2009 19:24:59 GMT
Server: Apache/1.3.33 (Darwin) mod_jk/1.2.2 PHP/4.4.1 DAV/1.0.3
Cache-Control: max-age=60
Expires: Wed, 11 Nov 2009 19:25:59 GMT
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
CLOSED xxx.xx.xxx.xx:80|6964
CLOSED xxx.xx.xxx.xx:80|6964
The put tForm statement produces this in the message box:
Content-type: multipart/form-data; boundary="__Part__4r1vvu74gmlute1h7jfpttm2x"
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="course"
MyCourse
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="firstname"
MyFirst
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="lastname"
MyLast
--__Part__4r1vvu74gmlute1h7jfpttm2x
Content-Disposition: form-data; name="uploaded_file"
/Users/MyLogon/*My Files Oct 2000/Student/Fred/StudCreat_MaryTurk/1257535622.png
--__Part__4r1vvu74gmlute1h7jfpttm2x--
Which looks a lot like the Live HTTP Headers output:
http://edtcserver.coe.tamu.edu/cgi-bin/ ... upload.cgi
POST /cgi-bin/homework_upload.cgi HTTP/1.1
Host: server.edu
User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://course.edu/Assignment-upload.html
Cookie: __utma=194481448.1246678664413041000.1242329551.1251401822.1253308902.7; __utmz=194481448.1251401822.6.2.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=employment%20TAMU; __utma=11651424.1159679486.1252518479.1252518479.1253297848.2; __utmz=11651424.1252518479.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Content-Type: multipart/form-data; boundary=---------------------------6475719317474173692004848058
Content-Length: 30978
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="course"
MyCourse
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="firstname"
MyFirst
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="lastname"
MyLast
-----------------------------6475719317474173692004848058
Content-Disposition: form-data; name="uploaded_file"; filename="1257535622.png"
Content-Type: image/jpeg
ˇÿˇ‡
HTTP/1.x 200 OK
Date: Wed, 11 Nov 2009 19:36:54 GMT
Server: Apache/1.3.33 (Darwin) mod_jk/1.2.2 PHP/4.4.1 DAV/1.0.3
Cache-Control: max-age=60
Expires: Wed, 11 Nov 2009 19:37:54 GMT
Keep-Alive: timeout=15, max=500
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=ISO-8859-1
I edited the paths & names to obscure the real information.
Not sure what else to try.
Thought it might be a problem because it is a graphics file but it didn't work with a text file either.
OK, there are some things to look at still, so we can get there in the end, I'm sure.
First up, your line looks wrong. You are putting that literal string into the variable, not the data. TryMake sure you include the parentheses.
You'll need to examine libUrlMultipartFormAddPart (form data,part name,value[,MIME type,encoding]) I think, in order to be able to set the image file part to the correct type in the form. Leave out the tUploaded_file from the libUrlMultipartFormData bit of the script, and add the image to the built-up form data with the libUrlMultipartFormAddPart function.
Some servers reject submissions from anywhere but their own domain, so you may have to "fake" the referer in your header with set httpHeaders.
Now it's clear from the LiveHTTPHeaders data you show that there are cookies which are set by the server - whether they are tested in order to validate any posts or just to preserve a session while navigating around the site is not clear though. As I mentioned before, you may need to get your RunRev app tofirst and then check the response from the server to look for the headers that "Set-Cookie" somewhere. You would then set the httpHeaders to include "Cookie:" with the cookie data that you extracted, as well as the rest of the header data.
Hope that gets you there in the end.
SparkOut
First up, your line
Code: Select all
Put "binfile:"&"/Users/myLogon/My Files/Students/Fred/StudCreat_MaryTurk/1257535622.png" into tUploaded_file
Code: Select all
Put url ("binfile:" & "/Users/myLogon/My Files/Students/Fred/StudCreat_MaryTurk/1257535622.png") into tUploaded_file
You'll need to examine libUrlMultipartFormAddPart (form data,part name,value[,MIME type,encoding]) I think, in order to be able to set the image file part to the correct type in the form. Leave out the tUploaded_file from the libUrlMultipartFormData bit of the script, and add the image to the built-up form data with the libUrlMultipartFormAddPart function.
Some servers reject submissions from anywhere but their own domain, so you may have to "fake" the referer in your header with set httpHeaders.
Now it's clear from the LiveHTTPHeaders data you show that there are cookies which are set by the server - whether they are tested in order to validate any posts or just to preserve a session while navigating around the site is not clear though. As I mentioned before, you may need to get your RunRev app to
Code: Select all
get url ("http://course.edu/Assignment-upload.html")
Hope that gets you there in the end.
SparkOut
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
Tried the code change
I tried the code change but that didn't fix the problem.
I'm finishing a deadline right now so must wait until next week to try to learn about the other features you mentioned; this server stuff gets a bit more complicated.
Thanks again for the input, I'll check back later.
Ron
I'm finishing a deadline right now so must wait until next week to try to learn about the other features you mentioned; this server stuff gets a bit more complicated.
Thanks again for the input, I'll check back later.
Ron
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
on-Rev instead
Since most of the problem seems to be related to getting through the university network, would it be easier to move this function to my new on-rev server account? I haven't used it yet, but this might be a good reason to switch.
Well, that's a big Mayyyyyybeeeeeee. It really depends on what you have setup for the University server and what you can set up on the on-Rev server to match. You couldn't get away with an unsecured submission in any case - especially when students' course results depend on the material being handled properly.
I don't suppose you could make a "safe" login that you wouldn't mind passing me to have a look and see what I can see might need to be done to successfully get rev to submit from outside?
If you can/would like to then I'll let you have my email address so as not to put even "sanitised" login data on the public forum.
I don't suppose you could make a "safe" login that you wouldn't mind passing me to have a look and see what I can see might need to be done to successfully get rev to submit from outside?
If you can/would like to then I'll let you have my email address so as not to put even "sanitised" login data on the public forum.
-
- Posts: 106
- Joined: Wed May 31, 2006 9:56 pm
- Contact:
Sounds good
Sure- what do you need? I can give you the links. I can set you up as a student so you can log on, or would you need more access than that? Since it is calling the CGI by its full address I think you can run the file from your computer. I'd need a little time to isolate the function from the full stack to make it convenient to access.
Actually, this is just the file upload part, no grading or records are involved. The grades, etc. are elsewhere, sometimes on another server, depends on the course. I use SQL, Some courses are all Moodle, and some access a FileMaker server (they all evolved over the years.)
Ron
Actually, this is just the file upload part, no grading or records are involved. The grades, etc. are elsewhere, sometimes on another server, depends on the course. I use SQL, Some courses are all Moodle, and some access a FileMaker server (they all evolved over the years.)
Ron
Hi Ron,
If you set up a fake student id and give me the login that will be all I need to check out how it should work. Presumably if I were to upload a file (an image of png type?) the cgi would handle the correct placement of the file according to the student ID? I don't need to use your stack to do that, I will just check that it's possible to connect and upload, first by doing it via a browser and then trying to recreate the situation in RunRev.
And what I meant by grading is that you obviously must be able to verify that a particular student has uploaded the material being graded, and that nobody else can upload anything else in its place or tamper with it anyhow. ergo an anonymous server is not really an option, is it?
If you can send me "safe" fake credentials and the submission page url to SparkOutYNY - at - gmail.com then I will take a look.
If you set up a fake student id and give me the login that will be all I need to check out how it should work. Presumably if I were to upload a file (an image of png type?) the cgi would handle the correct placement of the file according to the student ID? I don't need to use your stack to do that, I will just check that it's possible to connect and upload, first by doing it via a browser and then trying to recreate the situation in RunRev.
And what I meant by grading is that you obviously must be able to verify that a particular student has uploaded the material being graded, and that nobody else can upload anything else in its place or tamper with it anyhow. ergo an anonymous server is not really an option, is it?
If you can send me "safe" fake credentials and the submission page url to SparkOutYNY - at - gmail.com then I will take a look.