RE: Re:Blob Type

gary adams <[email protected]> Tue, 8 Sep 2009 06:04:42 -0400
Newsgroups gmane.comp.java.orm.simpleorm
Message-ID <[email protected]>

I use a byte arrays to deal with PDF and images that are defined and longblobs in mysql
 
public void setContent(String fieldName, byte[] val) {
    this.setBytes(SFieldBytes, val);
}

 

public byte[] getContent() {
     return getBytes(SFieldBytes); 
}


 
//To save the content to a file i use something like this
 
public void saveAsFile(String filePath) {

try {
OutputStream out = new FileOutputStream(filePath);
out.write(this.getContent());
out.close();
return;
} catch (Exception x) {
throw new RuntimeException("cant save doc to file", x);
}
}


 
 
hope this helps
GA

 


To: [email protected]
From: [email protected]
Date: Tue, 8 Sep 2009 12:25:18 +0300
Subject: [SimpleORM] Re:Blob Type

  



Hello all,

I was wondering how best to work with images and/or documents that I want to save in a db based on the SFieldBlob data type. Once I have retrieved the file (eg image) from a web page, should I immiately pass it as a blob type such as "setBlob(SrecordMeta.BlobField, getUploadFile) or do I have to write some code to convert it into some kind of byte array and then pass it to the blob type? Kindly assist.

Regards.

Abel








_________________________________________________________________
HotmailĀ® is up to 70% faster. Now good news travels really fast. 
http://windowslive.com/online/hotmail?ocid=PID23391::T:WLMTAGL:ON:WL:en-US:WM_HYGN_faster:082009