Webobjects WebServices - howto stream large Binary Objects
Kristof Cossement <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.devel |
|---|---|
| Message-ID | <[email protected]> |
I want to use webobjects for creating webservices to send large
binary files (eg a zipfile of 200Mb)
This works for small data objects (like a jpg of 50kB)
The problem is the data is not getting streamed, but the entire file
is being read in memory, which causes stack overflows.
Could someone give me a hint on how I can communicate through
webservices with large binary data objects?
This is an extract of the code I use:
WebService Consumer (Project 1)
============================
FileInputStream is = new FileInputStream("/path/to/file");
NSData d = new NSData(is,1024); // CRASHES HERE !!!
Object [] params = new Object[1];
params[0] = d;
WOWebServiceClient client = new WOWebServiceClient();
// extra initialisation here
Object result = client.invoke("FileUpload", "upload", params);
This is the WebService (Project 2)
================================
// I create a routine with an "NSData" parameter and register it as a
webservice
WOWebServiceRegistrar.registerWebService(FileUpload.class, true);
import java.io.*;
import com.webobjects.foundation.*;
public class FileUpload {
public static boolean upload(NSData d) {
//OutputStream stream
try {
FileOutputStream fileOutputStream = new FileOutputStream("/tmp/
file");
d.writeToStream(fileOutputStream);
fileOutputStream.close();
}
catch (IOException exception) {
// Do something with the exception
}
return true;
}
}
This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information and/or information protected by intellectual property rights.
If you are not the intended recipient, please note that any review, dissemination, disclosure, alteration, printing, copying or transmission of this e-mail and/or any file transmitted with it, is strictly prohibited and may be unlawful.
If you have received this e-mail by mistake, please immediately notify the sender and permanently delete the original as well as any copy of any e-mail and any printout thereof.
We may monitor e-mail to and from our network.
NSS nv
Tieltstraat 167
8740 Pittem
Belgium
_______________________________________________
WebObjects-dev mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/webobjects-dev