multipart upload become garbage
multipart upload become garbage
- Subject: multipart upload become garbage
- From: Yung-Luen Lan <email@hidden>
- Date: Thu, 16 Sep 2010 07:14:42 +0800
Hi,
The following code receives one chunk of multipart uploads and
appending it to a file.
(I have a client app which split the file first and then send the
chunks one by one.)
However, I got trouble when I deploy the code to a snow leopard
machine. I found the file uploaded is not the same as the original
file.
It seems that if there is byte '\0' occurred in the upload stream, the
succeeding bytes all becomes zero.
But this code used to work on both my old server (10.5, WO 5.4.2, Java
1.6 32bit) and dev machine (10.6, WO 5.4.2, Java 1.6 64bit)
What could possibly get wrong?
Regards,
yllan
=====
try {
WORequest r = context().request();
WOMultipartIterator iterator = r.multipartIterator();
WOMultipartIterator.WOFormData data = null;
NSData fileData = null;
while ((data = iterator.nextFormData()) != null) {
if (data.isFileUpload()) {
try {
InputStream stream = data.formDataInputStream();
fileData = new NSData(stream, 4096);
} catch (Exception e) {
return makeErrorXMLResponse(n, "UPLOAD: Failed to read Data from Stream.");
}
}
}
if (fileData == null)
return makeErrorXMLResponse(n, "UPLOAD: Failed to read data from request.");
fileData.writeToStream(session().pdfStream());
} catch (Exception e) {
return makeErrorXMLResponse(n, "UPLOAD: " + e.toString());
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden