Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] THANK YOU! (was Re: Re: retrieve-user-data needs help)

From: ryan::christiansen::intellisol::com at: 4-May-2001 14:47

Thank you, Scott, for digging this up! I can now upload large files using multipart/form-data. See for yourself by uploading a nice big browser-capable image here... http://www.fargonews.com/post-data.html The updated function follows... decode-multipart: make object! [ form-data: func [ ][ post-data: make string! 100000 while [0 < read-io system/ports/input post-data 100000] [] post-data: make binary! post-data parse/all post-data [to "----" copy text thru "^/" (boundary: copy text)] cd-block: [] parse/all post-data [ any [thru boundary copy text [to boundary | to end] (text: make binary! text append cd-block text)]] cd-input: [] foreach cd cd-block [ either find cd "filename" [ parse/all cd [thru {name="} copy text to {"} (append cd-input text)] parse/all cd [thru {filename="} copy text to {"} (file-path-string: copy text)] file-path-block: parse/all file-path-string {\/"} filename: last file-path-block parse/all cd [thru {Content-Type: } copy text to {^M^/} (file-mime-type: copy text)] ; parse/all cd [thru {^M^/^M^/} copy text to {^M^/} (text: make binary! text append cd-input text)] parse/all cd [thru {^M^/^M^/} copy text [to boundary | to end] (text: make binary! text append cd-input text)] ][ parse/all cd [thru {name="} copy text to {"} (append cd-input text)] parse/all cd [thru {^M^/^M^/} copy text to {^M^/} (append cd-input text)] ] ] cd-input: head cd-input object-data: make object! [] for x 1 (length? cd-input) 2 [ variable: first cd-input cd-input: next cd-input value: first cd-input either binary? value [ make-object-data: reform [rejoin [{object-data: make object-data [} (variable) {: } (value) {]}]] ][ make-object-data: reform [rejoin [{object-data: make object-data [} (variable) {: ^{} (value) {^}]}]] ] do make-object-data cd-input: next cd-input ] make-object-data: reform [rejoin [{object-data: make object-data [filename: ^{} (filename) {^}]}]] do make-object-data make-object-data: reform [rejoin [{object-data: make object-data [file-mime-type: ^{} (file-mime-type) {^}]}]] do make-object-data object-data ] ] Ryan C. Christiansen Web Developer Intellisol International 4733 Amber Valley Parkway Fargo, ND 58104 701-235-3390 ext. 6671 FAX: 701-235-9940 http://www.intellisol.com Global Leader in People Performance Software _____________________________________ Confidentiality Notice This message may contain privileged and confidential information. If you think, for any reason, that this message may have been addressed to you in error, you must not disseminate, copy or take any action in reliance on it, and we would ask you to notify us immediately by return email to [ryan--christiansen--intellisol--com] "GS Jones" <[gjones05--mail]. To: <[rebol-list--rebol--com]> orion.org> cc: Sent by: Subject: [REBOL] Re: retrieve-user-data needs help [rebol-bounce--re] bol.com 05/04/2001 07:16 AM Please respond to rebol-list From: <[ryan--christiansen--intellisol--com]>
> I'm trying to incorporate my 'decode-multipart/form-data function into
the
> commonly used 'retrieve-user-data function, but I am getting something > wrong. The function works now for GET operations but not for POST. > > If I use 'read-io on system/ports/input, that clears the port, correct? <snip>
Hi, Ryan, On May 2nd on a different thread ("read bug?"), Holger said (excerpt): <excerpt> About the other problem, i.e. getting data from a POST request within a REBOL CGI script: keep in mind that read-io is a very-low-level read request that returns as soon as the OS returns something. The amount of data returned is not necessarily what was requested. It can be less. This is not a bug, it is by design. If you see a limit of around 4096 bytes then this is caused by how the OS clusters its data. What you need to do in a CGI script is loop until read-io returns 0, e.g. cgi-str: make string! 100000 while [0 < read-io system/ports/input cgi-str 100000] [] </excerpt> I've not had a chance to play with this approach. Maybe it will help. --Scott Jones