[fileupload] Maximum size for upload?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[fileupload] Maximum size for upload?

Martin Grogan
Hi all,
Some time ago, I posted a question (and subsequently a code solution)
relating to JPEG scaling. This issue has now been resolved, and I am
working on storing images uploaded to a mySQL database as BLOBs
(MEDIUMBLOB).
It seems that when the image size is > 65535 bytes, the bottom of the
image is chopped off, and I am left with an image that is exactly 65535
bytes.
If anyone has any ideas on why this might be happening, and how I can
resolve it, I would be grateful.
Many thanks,
Martin

Some of the code I'm using is here...
     
                    ..............................
                    BufferedImage origImage = new
BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
                     java.awt.Graphics2D graphics2D2 =
origImage.createGraphics();                                            
                   
graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTERPOLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                   graphics2D2.drawImage(image, 0, 0, imageWidth,
imageHeight, null);
                    // get output stream from image                  
                    ByteArrayOutputStream os2= new ByteArrayOutputStream();
                    ImageIO.write(origImage,"jpeg",os2);                  
                    byte[] orig= os2.toByteArray();
                    // setup input stream for blob                  
                    ByteArrayInputStream inStream2= new
ByteArrayInputStream(orig);
                    try
                    {
                        Class.forName( "com.mysql.jdbc.Driver");
                        Connection
connection=DriverManager.getConnection("jdbc:mysql://localhost/gallery","gallery","gallery");    
       
                        String query="INSERT INTO img (name, pic) VALUES
('";                      
                        query=query+"picture',";
                        query=query+"?"+")";
                        PreparedStatement statement =
connection.prepareStatement(query);                        
                     
                       
//statement.setBinaryStream(1,inStream2,orig.length);                        
// doesn't seem to work either
                        statement.setBytes(1,orig);
                        ....................

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [fileupload] Maximum size for upload?

Knezevic, Mihael
i definitly uploaded a file of more than 40mb via the fileupload lib. so the size shouldn't be the problem.

first i would check the length of the array orig after the following line:
byte[] orig= os2.toByteArray();

then if would double check the definition of the columns in the table.

good luck.

mk

> -----Original Message-----
> From: Martin Grogan [mailto:[hidden email]]
> Sent: Thursday, July 28, 2005 8:49 AM
> To: Jakarta Commons Users List; [hidden email]
> Subject: [fileupload] Maximum size for upload?
>
> Hi all,
> Some time ago, I posted a question (and subsequently a code solution)
> relating to JPEG scaling. This issue has now been resolved, and I am
> working on storing images uploaded to a mySQL database as BLOBs
> (MEDIUMBLOB).
> It seems that when the image size is > 65535 bytes, the bottom of the
> image is chopped off, and I am left with an image that is
> exactly 65535
> bytes.
> If anyone has any ideas on why this might be happening, and how I can
> resolve it, I would be grateful.
> Many thanks,
> Martin
>
> Some of the code I'm using is here...
>      
>                     ..............................
>                     BufferedImage origImage = new
> BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
>                      java.awt.Graphics2D graphics2D2 =
> origImage.createGraphics();                                  
>          
>                    
> graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
> POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
>                    graphics2D2.drawImage(image, 0, 0, imageWidth,
> imageHeight, null);
>                     // get output stream from image                  
>                     ByteArrayOutputStream os2= new
> ByteArrayOutputStream();
>                     ImageIO.write(origImage,"jpeg",os2);      
>            
>                     byte[] orig= os2.toByteArray();
>                     // setup input stream for blob                  
>                     ByteArrayInputStream inStream2= new
> ByteArrayInputStream(orig);
>                     try
>                     {
>                         Class.forName( "com.mysql.jdbc.Driver");
>                         Connection
> connection=DriverManager.getConnection("jdbc:mysql://localhost
> /gallery","gallery","gallery");    
>        
>                         String query="INSERT INTO img (name,
> pic) VALUES
> ('";                      
>                         query=query+"picture',";
>                         query=query+"?"+")";
>                         PreparedStatement statement =
> connection.prepareStatement(query);                        
>                      
>                        
> //statement.setBinaryStream(1,inStream2,orig.length);        
>                
> // doesn't seem to work either
>                         statement.setBytes(1,orig);
>                         ....................
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [fileupload] Maximum size for upload?

Martin Grogan
Hi Mihael,
I've checked the size of the array, it is 89K, which is about right. It
is also definately being placed into a MEDIUMBLOB which I think is 2^24
bytes max. There shouldn't be a problem there.
I'm wondering if it's a problem with setting the stream for the
preparedStatement, i.e.
   
//statement.setBinaryStream(1,inStream2,orig.length);                        
// setBinaryStream no good ??
     statement.setBytes(1,orig);
Thanks,
Martin


Knezevic, Mihael wrote:

>i definitly uploaded a file of more than 40mb via the fileupload lib. so the size shouldn't be the problem.
>
>first i would check the length of the array orig after the following line:
>byte[] orig= os2.toByteArray();
>
>then if would double check the definition of the columns in the table.
>
>good luck.
>
>mk
>
>  
>
>>-----Original Message-----
>>From: Martin Grogan [mailto:[hidden email]]
>>Sent: Thursday, July 28, 2005 8:49 AM
>>To: Jakarta Commons Users List; [hidden email]
>>Subject: [fileupload] Maximum size for upload?
>>
>>Hi all,
>>Some time ago, I posted a question (and subsequently a code solution)
>>relating to JPEG scaling. This issue has now been resolved, and I am
>>working on storing images uploaded to a mySQL database as BLOBs
>>(MEDIUMBLOB).
>>It seems that when the image size is > 65535 bytes, the bottom of the
>>image is chopped off, and I am left with an image that is
>>exactly 65535
>>bytes.
>>If anyone has any ideas on why this might be happening, and how I can
>>resolve it, I would be grateful.
>>Many thanks,
>>Martin
>>
>>Some of the code I'm using is here...
>>      
>>                    ..............................
>>                    BufferedImage origImage = new
>>BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
>>                     java.awt.Graphics2D graphics2D2 =
>>origImage.createGraphics();                                  
>>        
>>                    
>>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
>>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
>>                   graphics2D2.drawImage(image, 0, 0, imageWidth,
>>imageHeight, null);
>>                    // get output stream from image                  
>>                    ByteArrayOutputStream os2= new
>>ByteArrayOutputStream();
>>                    ImageIO.write(origImage,"jpeg",os2);      
>>            
>>                    byte[] orig= os2.toByteArray();
>>                    // setup input stream for blob                  
>>                    ByteArrayInputStream inStream2= new
>>ByteArrayInputStream(orig);
>>                    try
>>                    {
>>                        Class.forName( "com.mysql.jdbc.Driver");
>>                        Connection
>>connection=DriverManager.getConnection("jdbc:mysql://localhost
>>/gallery","gallery","gallery");    
>>      
>>                        String query="INSERT INTO img (name,
>>pic) VALUES
>>('";                      
>>                        query=query+"picture',";
>>                        query=query+"?"+")";
>>                        PreparedStatement statement =
>>connection.prepareStatement(query);                        
>>                      
>>                        
>>//statement.setBinaryStream(1,inStream2,orig.length);        
>>              
>>// doesn't seem to work either
>>                        statement.setBytes(1,orig);
>>                        ....................
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [fileupload] Maximum size for upload?

Knezevic, Mihael
In reply to this post by Martin Grogan
java docs (1.5):

<quote>
setBytes:

Sets the designated parameter to the given Java array of bytes. The driver converts this to an SQL VARBINARY or LONGVARBINARY  (depending on the argument's size relative to the driver's limits on VARBINARY values) when it sends it to the database.
</quote>

perhaps you should try to use a blob object and use setBlob. perhaps the SerialBlob class helps. i got no experience with blobs so this is just a suggestion which doesn't have to work.


> -----Original Message-----
> From: Martin Grogan [mailto:[hidden email]]
> Sent: Thursday, July 28, 2005 9:10 AM
> To: Jakarta Commons Users List
> Subject: Re: [fileupload] Maximum size for upload?
>
> Hi Mihael,
> I've checked the size of the array, it is 89K, which is about
> right. It
> is also definately being placed into a MEDIUMBLOB which I
> think is 2^24
> bytes max. There shouldn't be a problem there.
> I'm wondering if it's a problem with setting the stream for the
> preparedStatement, i.e.
>    
> //statement.setBinaryStream(1,inStream2,orig.length);        
>                
> // setBinaryStream no good ??
>      statement.setBytes(1,orig);
> Thanks,
> Martin
>
>
> Knezevic, Mihael wrote:
>
> >i definitly uploaded a file of more than 40mb via the
> fileupload lib. so the size shouldn't be the problem.
> >
> >first i would check the length of the array orig after the
> following line:
> >byte[] orig= os2.toByteArray();
> >
> >then if would double check the definition of the columns in
> the table.
> >
> >good luck.
> >
> >mk
> >
> >  
> >
> >>-----Original Message-----
> >>From: Martin Grogan [mailto:[hidden email]]
> >>Sent: Thursday, July 28, 2005 8:49 AM
> >>To: Jakarta Commons Users List; [hidden email]
> >>Subject: [fileupload] Maximum size for upload?
> >>
> >>Hi all,
> >>Some time ago, I posted a question (and subsequently a code
> solution)
> >>relating to JPEG scaling. This issue has now been resolved,
> and I am
> >>working on storing images uploaded to a mySQL database as BLOBs
> >>(MEDIUMBLOB).
> >>It seems that when the image size is > 65535 bytes, the
> bottom of the
> >>image is chopped off, and I am left with an image that is
> >>exactly 65535
> >>bytes.
> >>If anyone has any ideas on why this might be happening, and
> how I can
> >>resolve it, I would be grateful.
> >>Many thanks,
> >>Martin
> >>
> >>Some of the code I'm using is here...
> >>      
> >>                    ..............................
> >>                    BufferedImage origImage = new
> >>BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
> >>                     java.awt.Graphics2D graphics2D2 =
> >>origImage.createGraphics();                                  
> >>        
> >>                    
> >>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
> >>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
> >>                   graphics2D2.drawImage(image, 0, 0, imageWidth,
> >>imageHeight, null);
> >>                    // get output stream from image        
>          
> >>                    ByteArrayOutputStream os2= new
> >>ByteArrayOutputStream();
> >>                    ImageIO.write(origImage,"jpeg",os2);      
> >>            
> >>                    byte[] orig= os2.toByteArray();
> >>                    // setup input stream for blob          
>          
> >>                    ByteArrayInputStream inStream2= new
> >>ByteArrayInputStream(orig);
> >>                    try
> >>                    {
> >>                        Class.forName( "com.mysql.jdbc.Driver");
> >>                        Connection
> >>connection=DriverManager.getConnection("jdbc:mysql://localhost
> >>/gallery","gallery","gallery");    
> >>      
> >>                        String query="INSERT INTO img (name,
> >>pic) VALUES
> >>('";                      
> >>                        query=query+"picture',";
> >>                        query=query+"?"+")";
> >>                        PreparedStatement statement =
> >>connection.prepareStatement(query);                        
> >>                      
> >>                        
> >>//statement.setBinaryStream(1,inStream2,orig.length);        
> >>              
> >>// doesn't seem to work either
> >>                        statement.setBytes(1,orig);
> >>                        ....................
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [hidden email]
> >>For additional commands, e-mail:
> [hidden email]
> >>
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [hidden email]
> >For additional commands, e-mail: [hidden email]
> >
> >
> >
> >  
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [fileupload] Maximum size for upload?

Knezevic, Mihael
In reply to this post by Martin Grogan
i would also take a look at the documentation at mysql.com. there are some points concerning blobs and prepared statements which could be important.

http://dev.mysql.com/doc/connector/j/en/cj-implementation-notes.html 

> -----Original Message-----
> From: Martin Grogan [mailto:[hidden email]]
> Sent: Thursday, July 28, 2005 9:10 AM
> To: Jakarta Commons Users List
> Subject: Re: [fileupload] Maximum size for upload?
>
> Hi Mihael,
> I've checked the size of the array, it is 89K, which is about
> right. It
> is also definately being placed into a MEDIUMBLOB which I
> think is 2^24
> bytes max. There shouldn't be a problem there.
> I'm wondering if it's a problem with setting the stream for the
> preparedStatement, i.e.
>    
> //statement.setBinaryStream(1,inStream2,orig.length);        
>                
> // setBinaryStream no good ??
>      statement.setBytes(1,orig);
> Thanks,
> Martin
>
>
> Knezevic, Mihael wrote:
>
> >i definitly uploaded a file of more than 40mb via the
> fileupload lib. so the size shouldn't be the problem.
> >
> >first i would check the length of the array orig after the
> following line:
> >byte[] orig= os2.toByteArray();
> >
> >then if would double check the definition of the columns in
> the table.
> >
> >good luck.
> >
> >mk
> >
> >  
> >
> >>-----Original Message-----
> >>From: Martin Grogan [mailto:[hidden email]]
> >>Sent: Thursday, July 28, 2005 8:49 AM
> >>To: Jakarta Commons Users List; [hidden email]
> >>Subject: [fileupload] Maximum size for upload?
> >>
> >>Hi all,
> >>Some time ago, I posted a question (and subsequently a code
> solution)
> >>relating to JPEG scaling. This issue has now been resolved,
> and I am
> >>working on storing images uploaded to a mySQL database as BLOBs
> >>(MEDIUMBLOB).
> >>It seems that when the image size is > 65535 bytes, the
> bottom of the
> >>image is chopped off, and I am left with an image that is
> >>exactly 65535
> >>bytes.
> >>If anyone has any ideas on why this might be happening, and
> how I can
> >>resolve it, I would be grateful.
> >>Many thanks,
> >>Martin
> >>
> >>Some of the code I'm using is here...
> >>      
> >>                    ..............................
> >>                    BufferedImage origImage = new
> >>BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
> >>                     java.awt.Graphics2D graphics2D2 =
> >>origImage.createGraphics();                                  
> >>        
> >>                    
> >>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
> >>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
> >>                   graphics2D2.drawImage(image, 0, 0, imageWidth,
> >>imageHeight, null);
> >>                    // get output stream from image        
>          
> >>                    ByteArrayOutputStream os2= new
> >>ByteArrayOutputStream();
> >>                    ImageIO.write(origImage,"jpeg",os2);      
> >>            
> >>                    byte[] orig= os2.toByteArray();
> >>                    // setup input stream for blob          
>          
> >>                    ByteArrayInputStream inStream2= new
> >>ByteArrayInputStream(orig);
> >>                    try
> >>                    {
> >>                        Class.forName( "com.mysql.jdbc.Driver");
> >>                        Connection
> >>connection=DriverManager.getConnection("jdbc:mysql://localhost
> >>/gallery","gallery","gallery");    
> >>      
> >>                        String query="INSERT INTO img (name,
> >>pic) VALUES
> >>('";                      
> >>                        query=query+"picture',";
> >>                        query=query+"?"+")";
> >>                        PreparedStatement statement =
> >>connection.prepareStatement(query);                        
> >>                      
> >>                        
> >>//statement.setBinaryStream(1,inStream2,orig.length);        
> >>              
> >>// doesn't seem to work either
> >>                        statement.setBytes(1,orig);
> >>                        ....................
> >>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [hidden email]
> >>For additional commands, e-mail:
> [hidden email]
> >>
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [hidden email]
> >For additional commands, e-mail: [hidden email]
> >
> >
> >
> >  
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [fileupload] Maximum size for upload?

Martin Grogan
Hi Mihael,
I found the solution (I think). The MaxFieldSize has to be set on the
client size, and the mySQL variable max_packet_size has to be set much
higher than the default.
One would assume that this would be more clearly documented on the mySQL
information site, etc.
Many thanks,
Martin


Knezevic, Mihael wrote:

>i would also take a look at the documentation at mysql.com. there are some points concerning blobs and prepared statements which could be important.
>
>http://dev.mysql.com/doc/connector/j/en/cj-implementation-notes.html 
>
>  
>
>>-----Original Message-----
>>From: Martin Grogan [mailto:[hidden email]]
>>Sent: Thursday, July 28, 2005 9:10 AM
>>To: Jakarta Commons Users List
>>Subject: Re: [fileupload] Maximum size for upload?
>>
>>Hi Mihael,
>>I've checked the size of the array, it is 89K, which is about
>>right. It
>>is also definately being placed into a MEDIUMBLOB which I
>>think is 2^24
>>bytes max. There shouldn't be a problem there.
>>I'm wondering if it's a problem with setting the stream for the
>>preparedStatement, i.e.
>>    
>>//statement.setBinaryStream(1,inStream2,orig.length);        
>>              
>>// setBinaryStream no good ??
>>     statement.setBytes(1,orig);
>>Thanks,
>>Martin
>>
>>
>>Knezevic, Mihael wrote:
>>
>>    
>>
>>>i definitly uploaded a file of more than 40mb via the
>>>      
>>>
>>fileupload lib. so the size shouldn't be the problem.
>>    
>>
>>>first i would check the length of the array orig after the
>>>      
>>>
>>following line:
>>    
>>
>>>byte[] orig= os2.toByteArray();
>>>
>>>then if would double check the definition of the columns in
>>>      
>>>
>>the table.
>>    
>>
>>>good luck.
>>>
>>>mk
>>>
>>>
>>>
>>>      
>>>
>>>>-----Original Message-----
>>>>From: Martin Grogan [mailto:[hidden email]]
>>>>Sent: Thursday, July 28, 2005 8:49 AM
>>>>To: Jakarta Commons Users List; [hidden email]
>>>>Subject: [fileupload] Maximum size for upload?
>>>>
>>>>Hi all,
>>>>Some time ago, I posted a question (and subsequently a code
>>>>        
>>>>
>>solution)
>>    
>>
>>>>relating to JPEG scaling. This issue has now been resolved,
>>>>        
>>>>
>>and I am
>>    
>>
>>>>working on storing images uploaded to a mySQL database as BLOBs
>>>>(MEDIUMBLOB).
>>>>It seems that when the image size is > 65535 bytes, the
>>>>        
>>>>
>>bottom of the
>>    
>>
>>>>image is chopped off, and I am left with an image that is
>>>>exactly 65535
>>>>bytes.
>>>>If anyone has any ideas on why this might be happening, and
>>>>        
>>>>
>>how I can
>>    
>>
>>>>resolve it, I would be grateful.
>>>>Many thanks,
>>>>Martin
>>>>
>>>>Some of the code I'm using is here...
>>>>    
>>>>                   ..............................
>>>>                   BufferedImage origImage = new
>>>>BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_INT_RGB);
>>>>                    java.awt.Graphics2D graphics2D2 =
>>>>origImage.createGraphics();                                  
>>>>        
>>>>                  
>>>>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
>>>>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
>>>>                  graphics2D2.drawImage(image, 0, 0, imageWidth,
>>>>imageHeight, null);
>>>>                   // get output stream from image        
>>>>        
>>>>
>>        
>>    
>>
>>>>                   ByteArrayOutputStream os2= new
>>>>ByteArrayOutputStream();
>>>>                   ImageIO.write(origImage,"jpeg",os2);      
>>>>          
>>>>                   byte[] orig= os2.toByteArray();
>>>>                   // setup input stream for blob          
>>>>        
>>>>
>>        
>>    
>>
>>>>                   ByteArrayInputStream inStream2= new
>>>>ByteArrayInputStream(orig);
>>>>                   try
>>>>                   {
>>>>                       Class.forName( "com.mysql.jdbc.Driver");
>>>>                       Connection
>>>>connection=DriverManager.getConnection("jdbc:mysql://localhost
>>>>/gallery","gallery","gallery");    
>>>>      
>>>>                       String query="INSERT INTO img (name,
>>>>pic) VALUES
>>>>('";                      
>>>>                       query=query+"picture',";
>>>>                       query=query+"?"+")";
>>>>                       PreparedStatement statement =
>>>>connection.prepareStatement(query);                        
>>>>                    
>>>>                      
>>>>//statement.setBinaryStream(1,inStream2,orig.length);        
>>>>              
>>>>// doesn't seem to work either
>>>>                       statement.setBytes(1,orig);
>>>>                       ....................
>>>>
>>>>------------------------------------------------------------
>>>>        
>>>>
>>---------
>>    
>>
>>>>To unsubscribe, e-mail: [hidden email]
>>>>For additional commands, e-mail:
>>>>        
>>>>
>>[hidden email]
>>    
>>
>>>>  
>>>>
>>>>        
>>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: [hidden email]
>>>For additional commands, e-mail: [hidden email]
>>>
>>>
>>>
>>>
>>>
>>>      
>>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [hidden email]
>>For additional commands, e-mail: [hidden email]
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [hidden email]
>For additional commands, e-mail: [hidden email]
>
>
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

RE: [fileupload] Maximum size for upload?

Knezevic, Mihael
In reply to this post by Martin Grogan
 

> -----Original Message-----
> From: Martin Grogan [mailto:[hidden email]]
> Sent: Thursday, July 28, 2005 11:06 AM
> To: Jakarta Commons Users List
> Subject: Re: [fileupload] Maximum size for upload?
>
> Hi Mihael,
> I found the solution (I think). The MaxFieldSize has to be set on the
> client size, and the mySQL variable max_packet_size has to be
> set much
> higher than the default.
good to know. i'm gonna save this mail in my "nice-to-know" folder =)

> One would assume that this would be more clearly documented
> on the mySQL
> information site, etc.
documentation is a difficult and much hated topic.
i made such assumptions more than once and have been proven wrong.
a colleague allways says the best and only docu is the source. the one who can read has the advantage.

thanx for the response.

mk

> Many thanks,
> Martin
>
>
> Knezevic, Mihael wrote:
>
> >i would also take a look at the documentation at mysql.com.
> there are some points concerning blobs and prepared
> statements which could be important.
> >
> >http://dev.mysql.com/doc/connector/j/en/cj-implementation-notes.html 
> >
> >  
> >
> >>-----Original Message-----
> >>From: Martin Grogan [mailto:[hidden email]]
> >>Sent: Thursday, July 28, 2005 9:10 AM
> >>To: Jakarta Commons Users List
> >>Subject: Re: [fileupload] Maximum size for upload?
> >>
> >>Hi Mihael,
> >>I've checked the size of the array, it is 89K, which is about
> >>right. It
> >>is also definately being placed into a MEDIUMBLOB which I
> >>think is 2^24
> >>bytes max. There shouldn't be a problem there.
> >>I'm wondering if it's a problem with setting the stream for the
> >>preparedStatement, i.e.
> >>    
> >>//statement.setBinaryStream(1,inStream2,orig.length);        
> >>              
> >>// setBinaryStream no good ??
> >>     statement.setBytes(1,orig);
> >>Thanks,
> >>Martin
> >>
> >>
> >>Knezevic, Mihael wrote:
> >>
> >>    
> >>
> >>>i definitly uploaded a file of more than 40mb via the
> >>>      
> >>>
> >>fileupload lib. so the size shouldn't be the problem.
> >>    
> >>
> >>>first i would check the length of the array orig after the
> >>>      
> >>>
> >>following line:
> >>    
> >>
> >>>byte[] orig= os2.toByteArray();
> >>>
> >>>then if would double check the definition of the columns in
> >>>      
> >>>
> >>the table.
> >>    
> >>
> >>>good luck.
> >>>
> >>>mk
> >>>
> >>>
> >>>
> >>>      
> >>>
> >>>>-----Original Message-----
> >>>>From: Martin Grogan [mailto:[hidden email]]
> >>>>Sent: Thursday, July 28, 2005 8:49 AM
> >>>>To: Jakarta Commons Users List; [hidden email]
> >>>>Subject: [fileupload] Maximum size for upload?
> >>>>
> >>>>Hi all,
> >>>>Some time ago, I posted a question (and subsequently a code
> >>>>        
> >>>>
> >>solution)
> >>    
> >>
> >>>>relating to JPEG scaling. This issue has now been resolved,
> >>>>        
> >>>>
> >>and I am
> >>    
> >>
> >>>>working on storing images uploaded to a mySQL database as BLOBs
> >>>>(MEDIUMBLOB).
> >>>>It seems that when the image size is > 65535 bytes, the
> >>>>        
> >>>>
> >>bottom of the
> >>    
> >>
> >>>>image is chopped off, and I am left with an image that is
> >>>>exactly 65535
> >>>>bytes.
> >>>>If anyone has any ideas on why this might be happening, and
> >>>>        
> >>>>
> >>how I can
> >>    
> >>
> >>>>resolve it, I would be grateful.
> >>>>Many thanks,
> >>>>Martin
> >>>>
> >>>>Some of the code I'm using is here...
> >>>>    
> >>>>                   ..............................
> >>>>                   BufferedImage origImage = new
> >>>>BufferedImage(imageWidth, imageHeight,
> BufferedImage.TYPE_INT_RGB);
> >>>>                    java.awt.Graphics2D graphics2D2 =
> >>>>origImage.createGraphics();                                  
> >>>>        
> >>>>                  
> >>>>graphics2D2.setRenderingHint(java.awt.RenderingHints.KEY_INTER
> >>>>POLATION,java.awt.RenderingHints.VALUE_INTERPOLATION_BILINEAR);
> >>>>                  graphics2D2.drawImage(image, 0, 0, imageWidth,
> >>>>imageHeight, null);
> >>>>                   // get output stream from image        
> >>>>        
> >>>>
> >>        
> >>    
> >>
> >>>>                   ByteArrayOutputStream os2= new
> >>>>ByteArrayOutputStream();
> >>>>                   ImageIO.write(origImage,"jpeg",os2);      
> >>>>          
> >>>>                   byte[] orig= os2.toByteArray();
> >>>>                   // setup input stream for blob          
> >>>>        
> >>>>
> >>        
> >>    
> >>
> >>>>                   ByteArrayInputStream inStream2= new
> >>>>ByteArrayInputStream(orig);
> >>>>                   try
> >>>>                   {
> >>>>                       Class.forName( "com.mysql.jdbc.Driver");
> >>>>                       Connection
> >>>>connection=DriverManager.getConnection("jdbc:mysql://localhost
> >>>>/gallery","gallery","gallery");    
> >>>>      
> >>>>                       String query="INSERT INTO img (name,
> >>>>pic) VALUES
> >>>>('";                      
> >>>>                       query=query+"picture',";
> >>>>                       query=query+"?"+")";
> >>>>                       PreparedStatement statement =
> >>>>connection.prepareStatement(query);                        
> >>>>                    
> >>>>                      
> >>>>//statement.setBinaryStream(1,inStream2,orig.length);        
> >>>>              
> >>>>// doesn't seem to work either
> >>>>                       statement.setBytes(1,orig);
> >>>>                       ....................
> >>>>
> >>>>------------------------------------------------------------
> >>>>        
> >>>>
> >>---------
> >>    
> >>
> >>>>To unsubscribe, e-mail:
> [hidden email]
> >>>>For additional commands, e-mail:
> >>>>        
> >>>>
> >>[hidden email]
> >>    
> >>
> >>>>  
> >>>>
> >>>>        
> >>>>
> >>>-----------------------------------------------------------
> ----------
> >>>To unsubscribe, e-mail: [hidden email]
> >>>For additional commands, e-mail:
> [hidden email]
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>      
> >>>
> >>------------------------------------------------------------
> ---------
> >>To unsubscribe, e-mail: [hidden email]
> >>For additional commands, e-mail:
> [hidden email]
> >>
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [hidden email]
> >For additional commands, e-mail: [hidden email]
> >
> >
> >
> >  
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]