Is there some sort of file upload size limit in Rails? I followed the Howto and am trying to upload into a mediumblob, but it only inserts 65k worth of data. I can manually insert more into my blobs, so I don''t think it''s a database issue. MySQL''s max_packet_size defaults to 1MB, so that shouldn''t be a problem. If I insert more than 65k, I can stream the data just fine from my rails app. I also added a LimitRequestBody directive in Apache, just in case the default was 65k, but I don''t think it is. I''m having this same issue on a Linux box and OSX, pointing at two different databases. My upload code looks like this: new_filename = File.basename(@params[''file''].original_filename) filename = new_filename.sub(/[^\w\.\-]/,''_'') file = Psmfile.new file.name = new_filename file.data = @params[''file''].read file.save Does anyone know what the problem might be? -- Ben Sinclair ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org
I had a similar problem and had to use longblob for it to work. PS did you mean to create ''filename'' but not use it? On 23/03/2005, at 10:56 AM, Ben Sinclair wrote:> Is there some sort of file upload size limit in Rails? I followed the > Howto and am trying to upload into a mediumblob, but it only inserts > 65k worth of data. I can manually insert more into my blobs, so I > don''t think it''s a database issue. MySQL''s max_packet_size defaults to > 1MB, so that shouldn''t be a problem. > > If I insert more than 65k, I can stream the data just fine from my > rails app. > > I also added a LimitRequestBody directive in Apache, just in case the > default was 65k, but I don''t think it is. > > I''m having this same issue on a Linux box and OSX, pointing at two > different databases. My upload code looks like this: > > new_filename = File.basename(@params[''file''].original_filename) > filename = new_filename.sub(/[^\w\.\-]/,''_'') > > file = Psmfile.new > file.name = new_filename > file.data = @params[''file''].read > file.save > > Does anyone know what the problem might be? > > -- > Ben Sinclair > ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
mediumblob takes 2mb. Thats what i use in snowdevil On Wed, 23 Mar 2005 11:06:01 +1200, Henry Maddocks <henryj-wUU9E3n5/m4qAMOr+u8IRA@public.gmane.org> wrote:> I had a similar problem and had to use longblob for it to work. > > PS did you mean to create ''filename'' but not use it? > > On 23/03/2005, at 10:56 AM, Ben Sinclair wrote: > > > Is there some sort of file upload size limit in Rails? I followed the > > Howto and am trying to upload into a mediumblob, but it only inserts > > 65k worth of data. I can manually insert more into my blobs, so I > > don''t think it''s a database issue. MySQL''s max_packet_size defaults to > > 1MB, so that shouldn''t be a problem. > > > > If I insert more than 65k, I can stream the data just fine from my > > rails app. > > > > I also added a LimitRequestBody directive in Apache, just in case the > > default was 65k, but I don''t think it is. > > > > I''m having this same issue on a Linux box and OSX, pointing at two > > different databases. My upload code looks like this: > > > > new_filename = File.basename(@params[''file''].original_filename) > > filename = new_filename.sub(/[^\w\.\-]/,''_'') > > > > file = Psmfile.new > > file.name = new_filename > > file.data = @params[''file''].read > > file.save > > > > Does anyone know what the problem might be? > > > > -- > > Ben Sinclair > > ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Tobi http://www.snowdevil.ca - Snowboards that don''t suck http://www.hieraki.org - Open source book authoring http://blog.leetsoft.com - Technical weblog
On Tue, 22 Mar 2005 16:56:49 -0600, Ben Sinclair <bensinc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Is there some sort of file upload size limit in Rails? I followed the > Howto and am trying to upload into a mediumblob, but it only inserts > 65k worth of data. I can manually insert more into my blobs, so I > don''t think it''s a database issue. MySQL''s max_packet_size defaults to > 1MB, so that shouldn''t be a problem. > > If I insert more than 65k, I can stream the data just fine from my rails app. > > I also added a LimitRequestBody directive in Apache, just in case the > default was 65k, but I don''t think it is. > > I''m having this same issue on a Linux box and OSX, pointing at two > different databases. My upload code looks like this: > > new_filename = File.basename(@params[''file''].original_filename) > filename = new_filename.sub(/[^\w\.\-]/,''_'') > > file = Psmfile.new > file.name = new_filename > file.data = @params[''file''].read > file.save > > Does anyone know what the problem might be?Is your form using GET or POST as its method?
I know. My images were ~150k and it was failing. Don''t know why but longblob worked. This is on OSX. On 23/03/2005, at 11:14 AM, Tobias Luetke wrote:> mediumblob takes 2mb. Thats what i use in snowdevil > > > On Wed, 23 Mar 2005 11:06:01 +1200, Henry Maddocks > <henryj-wUU9E3n5/m4qAMOr+u8IRA@public.gmane.org> wrote: >> I had a similar problem and had to use longblob for it to work. >> >> PS did you mean to create ''filename'' but not use it? >> >> On 23/03/2005, at 10:56 AM, Ben Sinclair wrote: >> >>> Is there some sort of file upload size limit in Rails? I followed the >>> Howto and am trying to upload into a mediumblob, but it only inserts >>> 65k worth of data. I can manually insert more into my blobs, so I >>> don''t think it''s a database issue. MySQL''s max_packet_size defaults >>> to >>> 1MB, so that shouldn''t be a problem. >>> >>> If I insert more than 65k, I can stream the data just fine from my >>> rails app. >>> >>> I also added a LimitRequestBody directive in Apache, just in case the >>> default was 65k, but I don''t think it is. >>> >>> I''m having this same issue on a Linux box and OSX, pointing at two >>> different databases. My upload code looks like this: >>> >>> new_filename = File.basename(@params[''file''].original_filename) >>> filename = new_filename.sub(/[^\w\.\-]/,''_'') >>> >>> file = Psmfile.new >>> file.name = new_filename >>> file.data = @params[''file''].read >>> file.save >>> >>> Does anyone know what the problem might be? >>> >>> -- >>> Ben Sinclair >>> ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org >>> _______________________________________________ >>> Rails mailing list >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >>> http://lists.rubyonrails.org/mailman/listinfo/rails >>> >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Tobi > http://www.snowdevil.ca - Snowboards that don''t suck > http://www.hieraki.org - Open source book authoring > http://blog.leetsoft.com - Technical weblog > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
I''m actually using longblobs now, just to try it, but it still doesn''t work. I am doing a POST, and if I make it write the file out instead of insert it into the database, it is the right size. The field was originally a blob. Does AR somehow not know I''ve changed it and tries to only write the maximum itself, or does it not care what type the field is? On Wed, 23 Mar 2005 11:37:50 +1200, Henry Maddocks <henryj-wUU9E3n5/m4qAMOr+u8IRA@public.gmane.org> wrote:> I know. My images were ~150k and it was failing. Don''t know why but > longblob worked. This is on OSX. > > On 23/03/2005, at 11:14 AM, Tobias Luetke wrote: > > > mediumblob takes 2mb. Thats what i use in snowdevil > > > > > > On Wed, 23 Mar 2005 11:06:01 +1200, Henry Maddocks > > <henryj-wUU9E3n5/m4qAMOr+u8IRA@public.gmane.org> wrote: > >> I had a similar problem and had to use longblob for it to work. > >> > >> PS did you mean to create ''filename'' but not use it? > >> > >> On 23/03/2005, at 10:56 AM, Ben Sinclair wrote: > >> > >>> Is there some sort of file upload size limit in Rails? I followed the > >>> Howto and am trying to upload into a mediumblob, but it only inserts > >>> 65k worth of data. I can manually insert more into my blobs, so I > >>> don''t think it''s a database issue. MySQL''s max_packet_size defaults > >>> to > >>> 1MB, so that shouldn''t be a problem. > >>> > >>> If I insert more than 65k, I can stream the data just fine from my > >>> rails app. > >>> > >>> I also added a LimitRequestBody directive in Apache, just in case the > >>> default was 65k, but I don''t think it is. > >>> > >>> I''m having this same issue on a Linux box and OSX, pointing at two > >>> different databases. My upload code looks like this: > >>> > >>> new_filename = File.basename(@params[''file''].original_filename) > >>> filename = new_filename.sub(/[^\w\.\-]/,''_'') > >>> > >>> file = Psmfile.new > >>> file.name = new_filename > >>> file.data = @params[''file''].read > >>> file.save > >>> > >>> Does anyone know what the problem might be? > >>> > >>> -- > >>> Ben Sinclair > >>> ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org > >>> _______________________________________________ > >>> Rails mailing list > >>> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >>> http://lists.rubyonrails.org/mailman/listinfo/rails > >>> > >> > >> _______________________________________________ > >> Rails mailing list > >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > >> http://lists.rubyonrails.org/mailman/listinfo/rails > >> > > > > > > -- > > Tobi > > http://www.snowdevil.ca - Snowboards that don''t suck > > http://www.hieraki.org - Open source book authoring > > http://blog.leetsoft.com - Technical weblog > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Ben Sinclair ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org
Well, I figured it out. I forgot to add a validation to my model, so when I uploaded new files I didn''t notice that I was uploading the same filename again and again. When pulling the file out, I was querying by the filename and getting the very first bad file that was added when the field was a plain blob instead of a large blob. As they say in a certain book, "Select isn''t broken!" On Wed, 23 Mar 2005 09:02:03 -0600, Ben Sinclair <bensinc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m actually using longblobs now, just to try it, but it still doesn''t > work. I am doing a POST, and if I make it write the file out instead > of insert it into the database, it is the right size.-- Ben Sinclair ben-bgLzOLc97kcYkl5+HhvCNA@public.gmane.org