hi ,
I want to store image data in mySQL database using rails.
I have created a table called "Photo_info" which have field called
"photo_data" and the data type of that field is "varchar".
My code is:
 path = "C:/test_sqs/public/images/rails.png"
   File.open(path, ''rb''){ |file| @data= file.read  }
When I am trying to store data in database, it gives error like:
"Could not log "sql.active_record" event. ArgumentError: invalid
byte
sequence in UTF-8"
what should i do?
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 28, 9:34 am, News Aanad <news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi , > I want to store image data in mySQL database using rails. > I have created a table called "Photo_info" which have field called > "photo_data" and the data type of that field is "varchar". > My code is: > > path = "C:/test_sqs/public/images/rails.png" > File.open(path, ''rb''){ |file| @data= file.read } > > When I am trying to store data in database, it gives error like: > > "Could not log "sql.active_record" event. ArgumentError: invalid byte > sequence in UTF-8" > > what should i do?varchar is the wrong column type. It''s almost certainly too short but beyond that it''s expecting text data, not arbitrary binary data. If you want to store stuff like that in the database you should be using a blob column (storing large files in the database isn''t usually that great of an idea though) Fred -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for Reply,
      But I want to do the same with amazon''s SimpleDB which deals only
with
String.
How can i do that?
Thanks in Advance
On Thu, Apr 28, 2011 at 2:35 PM, Frederick Cheung <
frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>
>
> On Apr 28, 9:34 am, News Aanad
<news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > hi ,
> > I want to store image data in mySQL database using rails.
> > I have created a table called "Photo_info" which have field
called
> > "photo_data" and the data type of that field is
"varchar".
> > My code is:
> >
> >  path = "C:/test_sqs/public/images/rails.png"
> >    File.open(path, ''rb''){ |file| @data= file.read  }
> >
> > When I am trying to store data in database, it gives error like:
> >
> > "Could not log "sql.active_record" event.
ArgumentError: invalid byte
> > sequence in UTF-8"
> >
> > what should i do?
>
> varchar is the wrong column type. It''s almost certainly too short
but
> beyond that it''s expecting text data, not arbitrary binary data.
If
> you want to store stuff like that in the database you should be using
> a blob column (storing large files in the database isn''t usually
that
> great of an idea though)
>
> Fred
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 28, 11:03 am, News Aanad <news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for Reply, > But I want to do the same with amazon''s SimpleDB which deals only with > String. > How can i do that? >I wouldn''t if I were you - attribute values are capped at 1024 bytes. If you want to store images in the amazon world, I''d use S3 Fred> Thanks in Advance > > On Thu, Apr 28, 2011 at 2:35 PM, Frederick Cheung < > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > On Apr 28, 9:34 am, News Aanad <news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > hi , > > > I want to store image data in mySQL database using rails. > > > I have created a table called "Photo_info" which have field called > > > "photo_data" and the data type of that field is "varchar". > > > My code is: > > > > path = "C:/test_sqs/public/images/rails.png" > > > File.open(path, ''rb''){ |file| @data= file.read } > > > > When I am trying to store data in database, it gives error like: > > > > "Could not log "sql.active_record" event. ArgumentError: invalid byte > > > sequence in UTF-8" > > > > what should i do? > > > varchar is the wrong column type. It''s almost certainly too short but > > beyond that it''s expecting text data, not arbitrary binary data. If > > you want to store stuff like that in the database you should be using > > a blob column (storing large files in the database isn''t usually that > > great of an idea though) > > > Fred > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thank you Fred. On Thu, Apr 28, 2011 at 4:35 PM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 28, 11:03 am, News Aanad <news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Thanks for Reply, > > But I want to do the same with amazon''s SimpleDB which deals only > with > > String. > > How can i do that? > > > I wouldn''t if I were you - attribute values are capped at 1024 bytes. > If you want to store images in the amazon world, I''d use S3 > > Fred > > Thanks in Advance > > > > On Thu, Apr 28, 2011 at 2:35 PM, Frederick Cheung < > > > > > > > > frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > On Apr 28, 9:34 am, News Aanad <news.anan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > hi , > > > > I want to store image data in mySQL database using rails. > > > > I have created a table called "Photo_info" which have field called > > > > "photo_data" and the data type of that field is "varchar". > > > > My code is: > > > > > > path = "C:/test_sqs/public/images/rails.png" > > > > File.open(path, ''rb''){ |file| @data= file.read } > > > > > > When I am trying to store data in database, it gives error like: > > > > > > "Could not log "sql.active_record" event. ArgumentError: invalid byte > > > > sequence in UTF-8" > > > > > > what should i do? > > > > > varchar is the wrong column type. It''s almost certainly too short but > > > beyond that it''s expecting text data, not arbitrary binary data. If > > > you want to store stuff like that in the database you should be using > > > a blob column (storing large files in the database isn''t usually that > > > great of an idea though) > > > > > Fred > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.