Thursday, July 7, 2011

Hibernate.createBlob with Apache HttpClient


I wanted to download a file with Apache HttpClient and save it as a blob with Hibernate.

HttpEntity httpEntity = response.getEntity();
Hibernate.createBlob(httpEntity.getContent(), (int) httpEntity.getContentLength());

The thing to note here is that the size of the file has to be specified by doing this(int) httpEntity.getContentLength()for it to work.

No comments:

Post a Comment