Hi,
What I'm trying to do is that if some parameter ex.) "sessionid" is valid then file upload session will be continued, if not, the current session will be cancelled. What part should I put session checking code? My current code is answerTo: aHTTPRequest | stream sidStream | aHTTPRequest postDataAt: 'file' beforeStreamingDo: [:datum | stream _ (SpFilename named: (self localNameFor: datum filename)) writeStream. datum writeStream: stream]. aHTTPRequest postDataAt: 'sessionid' beforeStreamingDo: [:datum | sidStream _ WriteStream on: (ByteArray new: 1000). datum writeStream: sidStream]. aHTTPRequest ensureFullRead. "to be sure streaming occurs" stream close. "mandatory, to close open stream! " Transcript show: sidStream contents asString; cr. sidStream close. ^HTTPResponse ok entity: 'OK' It seems that only after all streaming is done, the sessionid value is readable. Thanks in advance. ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
S.J.Chun wrote:
> What I'm trying to do is that if some parameter ex.) "sessionid" is valid > then file upload session will be continued, if not, the current session will be > cancelled. What part should I put session checking code? Before file input field. That way you'll have a value read and parsed from request before reading/streaming the actual file starts. Input field order is therefore important. You need to put all input fields (whose values you'll need later for streaming) before the streamed input fields. Note also that not only file uploads but any post data can be streamed. If you look at the code it is actually already streamed internally just to the temporary stream. To stream some other form input, simply use the same method #postDataAt:beforeStreamingDo: for that form element too. Best regards Janko > > My current code is > > answerTo: aHTTPRequest > | stream sidStream | > aHTTPRequest > postDataAt: 'file' > beforeStreamingDo: [:datum | > stream _ (SpFilename named: (self localNameFor: datum filename)) writeStream. > datum writeStream: stream]. > > aHTTPRequest > postDataAt: 'sessionid' > beforeStreamingDo: [:datum | > sidStream _ WriteStream on: (ByteArray new: 1000). > datum writeStream: sidStream]. > > aHTTPRequest ensureFullRead. "to be sure streaming occurs" > stream close. "mandatory, to close open stream! " > > Transcript show: sidStream contents asString; cr. > sidStream close. > > ^HTTPResponse ok > entity: 'OK' > > It seems that only after all streaming is done, the sessionid value is readable. > > Thanks in advance. > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > Swazoo-devel mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/swazoo-devel > -- Janko Mivšek AIDA/Web Smalltalk Web Application Server http://www.aidaweb.si ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
>>>>> "Janko" == Janko Mivšek <[hidden email]> writes:
Janko> Input field order is therefore important. You need to put all input Janko> fields (whose values you'll need later for streaming) before the Janko> streamed input fields. Input field order is not guaranteed in the CGI (draft) spec though. A conforming client is free to send out the fields in alphabetical or random order, for example. There's no "before" that can be guaranteed. You'd have to do this as two steps. The submit button could fire AJAX that says "the stream's a'comin'!"... and then after a server confirmation, submit the stream form. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 <[hidden email]> <URL:http://www.stonehenge.com/merlyn/> Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
In reply to this post by Chun, Sungjin
Hi,
I cannot read other input field value; for example to read sessionid, I've written following code but it does print "nil". answerTo: aHTTPRequest aHTTPRequest postDataAt: 'sessionid' beforeStreamingDo: [:datum | Transcript show: datum value; cr. ]. I though the value of 'sessionid' will be printed on Transcript window. What's wrong? Thanks in advance. ----- Original Message ----- From: Janko Mivšek <[hidden email]> To: "S.J.Chun" <[hidden email]>, Swazoo Development Discussions <[hidden email]> Sent: 08-07-31 00:24:04 Subject: Re: [Swazoo-devel] [Q] Conditional streaming of file upload S.J.Chun wrote: > What I'm trying to do is that if some parameter ex.) "sessionid" is valid > then file upload session will be continued, if not, the current session will be > cancelled. What part should I put session checking code? Before file input field. That way you'll have a value read and parsed from request before reading/streaming the actual file starts. Input field order is therefore important. You need to put all input fields (whose values you'll need later for streaming) before the streamed input fields. Note also that not only file uploads but any post data can be streamed. If you look at the code it is actually already streamed internally just to the temporary stream. To stream some other form input, simply use the same method #postDataAt:beforeStreamingDo: for that form element too. Best regards Janko ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
In reply to this post by Chun, Sungjin
Hmm,
it seems that I cannot read value of parameter until ensureFullRead is done. The problem is that I cannot disconnect or return error message until all file uploading is finished. How can I read a value during stream parsing? For example, if "sessionid" is first field and "file" is second field, then I can read "sessionid" first. And if read-in "sessionid" is wrong, I just want to reply with string 'NO'. How can I acheive this? Thank you in advance. ----- Original Message ----- From: "S.J.Chun" <[hidden email]> To: Swazoo Development Discussions <[hidden email]>, Janko Mivšek <[hidden email]> Sent: 08-07-31 12:23:17 Subject: Re: [Swazoo-devel] [Q] Conditional streaming of file upload Hi, I cannot read other input field value; for example to read sessionid, I've written following code but it does print "nil". answerTo: aHTTPRequest aHTTPRequest postDataAt: 'sessionid' beforeStreamingDo: [:datum | Transcript show: datum value; cr. ]. I though the value of 'sessionid' will be printed on Transcript window. What's wrong? Thanks in advance. ----- Original Message ----- From: Janko Mivšek <[hidden email]> To: "S.J.Chun" <[hidden email]>, Swazoo Development Discussions <[hidden email]> Sent: 08-07-31 00:24:04 Subject: Re: [Swazoo-devel] [Q] Conditional streaming of file upload S.J.Chun wrote: > What I'm trying to do is that if some parameter ex.) "sessionid" is valid > then file upload session will be continued, if not, the current session will be > cancelled. What part should I put session checking code? Before file input field. That way you'll have a value read and parsed from request before reading/streaming the actual file starts. Input field order is therefore important. You need to put all input fields (whose values you'll need later for streaming) before the streamed input fields. Note also that not only file uploads but any post data can be streamed. If you look at the code it is actually already streamed internally just to the temporary stream. To stream some other form input, simply use the same method #postDataAt:beforeStreamingDo: for that form element too. Best regards Janko ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Swazoo-devel mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/swazoo-devel |
Free forum by Nabble | Edit this page |