Minor correction to EOF code below:

File file = …;
FileInputStream stream = new FileInputStream(file);
NSData data = new NSData(stream, 1024);
FileContent fileContent = FileContent.create(editingContext);
fileContent.setContent(data);
editingContext.saveChanges();



> On Apr 6, 2017, at 7:03 PM, Ricardo Parada <rpar...@mac.com> wrote:
> 
> Hi all,
> 
> Using JDBC I can stream the contents of a file to the database as follows:
> 
> File file = …;
> FileInputStream stream = new FileInputStream(file);
> PreparedStatement ps = connection.prepareStatement("INSERT INTO FILE_CONTENT 
> (ID, CONTENT) VALUES (?,?)");
> ps.setString(1, fileContentID);
> ps.setBinaryStream(2, stream, (int)file.length());
> ps.execute();
> ps.close();
> connection.close();
> 
> Is it possible to do something similar in EOF.  I thought that maybe if I 
> created the NSData like this:
> 
> File file = …;
> FileInputStream stream = new FileInputStream(file);
> NSData data = new NSData(stream, 1024);
> FileContent fileContent = FileContent.create(editingContext);
> mimeContent.setContent(data);
> editingContext.saveChanges();
> 
> However, creating the NSData object with the stream seems to read all the 
> data into memory.
> 
> Is it possible to do this in EOF?  I'd prefer to use EOF so that I don't have 
> to create a new connection to the database to do this.
> 
> Thanks
> Ricardo Parada
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/webobjects-dev/rparada%40mac.com
> 
> This email sent to rpar...@mac.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to