You mean something like:
import java.io.*;
public class GetBytes( File imageFile) throws IOException {
// set size of array to n megabytes
double bytes = n * 1024 * 1024;
double imageBytes;
imageFile = new File( imageFile)
BufferedOutputStream bos = new BufferedOutputStream( new
FileOutputStream( imageFile), bytes);
// get the size of the image file
imageBytes = bos.count();
// write out the file for the database
bos.write( imageFile);
}
I realize there is some overhead here, but I can't think of any
other way to get the size of the input stream (in this case you
feed the input from the servlet getting the image through
GetBytes). But why not just serialize the image file object and
store it directly into the database? Is there a need to know the
file size? Deserializing an image object from a database is
fairly trivial if the client UI is Java.
Mark
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "Mark Galbreath" <[EMAIL PROTECTED]>
Sent: Tuesday, April 17, 2001 12:46 PM
Subject: Re: Length of InputStream
>
>
> Mark
>
> What i am trying to do is upload images and save them as binary
data in to the
> database. No currently i upload the file and write it to the
server and than
> from there read it as FileInputStream and then save it into the
DB. I want to
> try and cut out the writing the file to the server bit and do
an insert in to
> the db directly. I am using the MultipartParser to get the form
data. Any help
> would be much appreciated.
>
> thanks
>
> Parag
>
>
>
>
> Mark Galbreath <[EMAIL PROTECTED]> on 17/04/2001 14:07:19
>
> Please respond to Mark Galbreath <[EMAIL PROTECTED]>
>
> To: [EMAIL PROTECTED]
> cc: (bcc: Parag Patwa/LON/WLB)
>
> Subject: Re: Length of InputStream
>
>
>
> Try Jason Hunter's "Java Servlet Programming," pp. 104-121.
> Specifically, getContentLength() and MultipartRequest.getFile(
> String name).length().
>
> Cheers!
> Mark
>
> ----- Original Message -----
> From: "Patwa Patwa" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 17, 2001 9:03 AM
> Subject: Length of InputStream
>
>
> > Hi
> >
> > Any one know how to get the length of an InputStream. I need
to
> upload the
> > InputStream to the database.
> >
> > thanks
> > Parag
> >
> >
> >
> >
> >
> >
> >
> > Diese Nachricht ist vertraulich. Sie ist ausschliesslich fuer
> > den im Adressfeld ausgewiesenen Adressaten bestimmt.
> > Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
> > wir um eine kurze Nachricht. Jede unbefugte Weiterleitung
> > oder Fertigung einer Kopie ist unzulaessig. Da wir nicht die
> > Echtheit oder Vollstaendigkeit der in dieser Nachricht
> > enthaltenen Informationen garantieren koennen, schliessen wir
> > die rechtliche Verbindlichkeit der vorstehenden Erklaerungen
> > und Aeusserungen aus. Wir verweisen in diesem Zusammenhang
> > auch auf die fuer die Bank geltenden Regelungen ueber die
> > Verbindlichkeit von Willenserklaerungen mit verpflichtendem
> > Inhalt, die in den bankueblichen Unterschriftenverzeichnissen
> > bekannt gemacht werden.
> >
> > This message is confidential and may be privileged. It is
> > intended solely for the named addressee. If you are not the
> > intended recipient please inform us. Any unauthorised
> > dissemination, distribution or copying hereof is prohibited.
> > As we cannot guarantee the genuineness or completeness of
> > the information contained in this message, the statements
> > set forth above are not legally binding. In connection
> > therewith, we also refer to the governing regulations of
> > WestLB concerning signatory authority published in the
> > standard bank signature lists with regard to the legally
> > binding effect of statements made with the intent to
> > obligate WestLB.
> >
> >
>
_________________________________________________________________
> __________
> > To unsubscribe, send email to [EMAIL PROTECTED] and
include
> in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives:
> http://archives.java.sun.com/archives/servlet-interest.html
> > Resources:
> http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
>
>
_________________________________________________________________
__________
> To unsubscribe, send email to [EMAIL PROTECTED] and include
in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives:
http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
>
>
>
>
>
>
>
>
>
>
> Diese Nachricht ist vertraulich. Sie ist ausschliesslich fuer
> den im Adressfeld ausgewiesenen Adressaten bestimmt.
> Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten
> wir um eine kurze Nachricht. Jede unbefugte Weiterleitung
> oder Fertigung einer Kopie ist unzulaessig. Da wir nicht die
> Echtheit oder Vollstaendigkeit der in dieser Nachricht
> enthaltenen Informationen garantieren koennen, schliessen wir
> die rechtliche Verbindlichkeit der vorstehenden Erklaerungen
> und Aeusserungen aus. Wir verweisen in diesem Zusammenhang
> auch auf die fuer die Bank geltenden Regelungen ueber die
> Verbindlichkeit von Willenserklaerungen mit verpflichtendem
> Inhalt, die in den bankueblichen Unterschriftenverzeichnissen
> bekannt gemacht werden.
>
> This message is confidential and may be privileged. It is
> intended solely for the named addressee. If you are not the
> intended recipient please inform us. Any unauthorised
> dissemination, distribution or copying hereof is prohibited.
> As we cannot guarantee the genuineness or completeness of
> the information contained in this message, the statements
> set forth above are not legally binding. In connection
> therewith, we also refer to the governing regulations of
> WestLB concerning signatory authority published in the
> standard bank signature lists with regard to the legally
> binding effect of statements made with the intent to
> obligate WestLB.
>
>
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html