Big correction!
It wasn't just adding 'name' atrribute to WOFileUpload element...
better still, that hasn't to do anything about it.
The thing that was broking all was that there was a method call which
went through the WOFormData iteratively to extract some partValue and
that caused the stream to be closed at the end of the loop which the
next read caused to be at the EOF. So rearranging code I was able to
not need to went through that loop and the file was read successfully.
-Carlos
On Jul 31, 2009, at 2:10 PM, Chuck Hill wrote:
On Jul 31, 2009, at 1:49 PM, Carlos Maldonado wrote:
Hi,
I'm debugging an app and can't find the exact cause of loosing the
contents of a file being uploaded. I know WO is capable of uploading
files, that's not the issue, even I tested using XCode with WO5.3 in
Tiger, Eclipse with WO5.4 in Leopard and finally using Eclipse with
WOnder 5.4 in Leopard. All worked with no problems. If I needed to
grab the file contents I could do it either in createRequest,
dispatchRequest or in the DA method or the action object-method in
case I wanted not to use DAs.
But then I moved to the non-working app and I can see file contents
in createRequest method --I can even save the file-- but as soon as
execution gets to dispatchRequest, and though I get a valid object
when I issue the call InputStream input =
part.formDataInputStream(); --input is valid object-- I don't get
any data from the call input.read(buffer, offset, length - offset);
or input.available() all I get is a -1 which means there's no data.
I don't have an awake method, that I think is the next method in
execution after createRequest gets called and before dispatchRequest
gets called too.
Does anybody had experienced something simliar? or have a clue of
what could be causing to loose data?. I checked the encoding for the
WOComponent and is set to UTF-8, so defaultFormValueEncoding=UTF-8
and formValueEncoding=UTF-8 are the same.
I'm not sure where, but I think the encoding is getting changed. Are
you using Wonder in this app? If yes, add this to the Properties
file:
er.extensions.ERXApplication.DefaultEncoding= UTF-8
Chuck
Here's the request that doesn't upload, see if someone can see it
different from "normal":
<com.webobjects.appserver.WORequest
(<com.webobjects.appserver.WORequest httpVersion=HTTP/1.1
headers={accept=[application/xml,application/xhtml+xml,text/
html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5], accept-
encoding=[gzip, deflate], accept-language=[en-us], connection=[keep-
alive], content-length=[14000], content-type=[multipart/form-data;
boundary=----WebKitFormBoundaryZ5DtuOIpu8QIP+zn], host=[localhost:
11021], origin=[http://localhost:11021], referer=[http://localhost:11021
/cgi-bin/WebObjects/LSDesktopServer.woa/wa/uploadFile], user-
agent=[Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_7; en-us)
AppleWebKit/530.19.2 (KHTML, like Gecko) Version/4.0.2 Safari/
530.19]} content-length=0 cookies=null userInfo={}
storePageInBacktrackCache=true >) method=POST uri=/cgi-bin/
WebObjects/LSDesktopServer.woa/wa/uploadPenDataMetrics?
filePathToUpload=%2Ftmp
%2FHola.java&userToken=090749684221rSHxwWRjQjhN
defaultFormValueEncoding=UTF-8 formValueEncodingDetectionEnabled=NO
formValueEncoding=UTF-8 formValues={1.0.mimetype = ("application/
octet-stream"); 1.0.filename = ("Hola1.java"); 1.0 = ( <class
com.webobjects.appserver._private.WOInputStreamData (stream
com.webobjects.appserver.WOMultipartIterator$WOFormData
$_woformdatainputstr...@7689bc of length 0), has NOT been
accessed> ); } >
-Carlos
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
This email sent to [email protected]
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]