World: r3wp
[Core] Discuss core issues
older newer | first last |
Oldes 30-May-2006 [4747x2] | Is there any script for ftp upload of large files? |
srcp: open/direct/read src trgp: open/direct/new/write trg while [not none? buf: copy/part srcp 1000][ prin "#" insert trgp buf ] insert trgp crlf close trgp close srcp | |
Anton 30-May-2006 [4749] | Does that work for FTP ? |
Oldes 30-May-2006 [4750x4] | yes:-))) the insert trgp crlf is not needed |
the trick is, thet there must be the /new switch in the ftp port (as at least my ftp server do not support append) | |
Hm, but now how to make directory thru FTP:( | |
ah it's easy as well, just using make-dir... I'm reboling so many years and still am so suprised how simple it can be:-) | |
Sunanda 30-May-2006 [4754] | Just be aware that make-dir/deep usually doesn't work with FTP |
Henrik 30-May-2006 [4755] | anton has a fix for that |
Anton 30-May-2006 [4756x2] | I found that make-dir/deep doesn't work, so I patched FTP OPEN so that it creates deep paths as necessary. |
This means you no longer have to worry about creating the directory, you only need to WRITE your file. | |
Sunanda 30-May-2006 [4758] | Though you may want to worry about the set-modes for the automatically created folders. |
Anton 30-May-2006 [4759x3] | http://home.wilddsl.net.au/anton/rebol/patch/ftp-open-new-patch.r |
set-modes ? what do you mean ? | |
You can also use the above patch to only create the path like this: | |
Sunanda 30-May-2006 [4762] | If you don't explicitly set the file permissions (under UNIX-deriviatives mainly) to precisely what you mean them to be, then they *may* be set to something other than what you wanted. That applies to all files and folders. http://www.rebol.com/docs/words/wset-modes.html I'm not suggesting your patch does something wrong.....Just that it may not do what someone expects. |
Anton 30-May-2006 [4763x2] | port: make port! ftp-spec port/state/flags: port/state/flags or system/standard/port-flags/open-new port/handler/open port |
Sunanda, good point indeed. | |
Joe 30-May-2006 [4765] | can anybody provide a simple example to explain copy and copy/deep behaviour ? thanks |
Sunanda 30-May-2006 [4766x2] | a: 1 b: [2] c: copy [] append c a append/only c b probe c d1: copy c d2: copy/deep c append b 99999 probe d1 probe d2 ====== d1 ends up with it's second entry the same as b d2 ends up with it's second entry a c opy of b's original values |
Other explainations here: http://www.rebol.org/cgi-bin/cgiwrap/rebol/ml-topic-index.r?i=copy | |
Joe 30-May-2006 [4768] | thanks, good examples |
Oldes 31-May-2006 [4769] | Anton, yout ftp patch was not working, but I solved the issue with missing directories using this code: while [ error? set/any 'err try [trgp: open/direct/new/write rejoin [ftp-url trg-dir trg-file]] ][ err: disarm err if all [ err/code = 800 parse err/arg1 [thru "tcp 550 " copy missingdir to ":" to end] ][ print ["Making directory:" join ftp-url missingdir] if error? try [make-dir join ftp-url missingdir][ trgp: none break ] ] ] |
Anton 31-May-2006 [4770] | Oldes, what FTP server did you try it with ? |
Oldes 31-May-2006 [4771x2] | the code above is not working either:-( |
It works only for one directory level:-) | |
Anton 31-May-2006 [4773] | How badly was my ftp patch not working ? :-) |
Oldes 31-May-2006 [4774] | it's not making missing dirs |
Anton 31-May-2006 [4775] | Did you get this net-error "Cannot open a dir port in direct mode" ? |
Oldes 31-May-2006 [4776] | ** User Error: Server error: tcp 550 httpdocs/test/1/2/: No such file or directory |
Anton 31-May-2006 [4777] | Are you sure the patch was applied correctly ? (uncomment the ;print "patch" line.) Perhaps your FTP scheme is already patched ? |
Oldes 31-May-2006 [4778x2] | and this one as well: ** User Error: Cannot open a dir port in direct mode |
if I use /direct | |
Anton 31-May-2006 [4780x4] | Ah that's right. |
Ok, I recommend to use open and close the port *not* in direct mode, just to create the directory. Then, try opening your port in direct mode to do the write. | |
Sorry, that wasn't very clear.. Use my code snippet above just to create the path. port: make port! ftp-spec ; only path, no target port/state/flags: port/state/flags or system/standard/port-flags/open-new port/handler/open port close port ; now try to open/direct ... etc.. | |
There is some debug info available with: trace/net on | |
Oldes 31-May-2006 [4784] | I found the problem, you have this: {Server error: tcp 550 Can't change directory to} thru {:} {No such file or directory} but my ftp server's response is only: Server error: tcp 550 httpdocs/test/1/2/: No such file or directory |
Anton 31-May-2006 [4785x3] | Aha..! yes, very good. I knew that piece of code was possibly brittle. (Thankyou FTP, thankyou.) |
Maybe I should just look for "tcp 550" what do you think ? | |
or parse response [thru "error" thru " tcp " thru " 550 "] | |
Oldes 31-May-2006 [4788] | yes, that's working now |
Anton 31-May-2006 [4789x2] | Cool. Does it work even in direct mode ? |
I think you can just open the port once now. | |
Oldes 31-May-2006 [4791x2] | no |
YES, it's working even in direct mode. But must use the file name as well | |
Anton 31-May-2006 [4793x2] | Yes, that's right, you would have got the "Cannot open a dir port in direct mode" error ? |
Congratulations. You successfully used my patch. :-) | |
Oldes 31-May-2006 [4795x2] | and I think, this should be enough: thru "tcp 550" to end |
lines 81 and 107 | |
older newer | first last |