Cornelius Jaeger | 3 Feb 2009 00:58
Picon

images in db

hi all

just working on my first camping hack and new to ruby as well.
i've figured some things out and uploading images into the database,  
but i'm not sure how to get the data displayed in the browser.
i'd like to stream it straight from the db, not copy it to the fs first.
obviously img(:src => file_data) doesn't work.
any pointers or reading assignments would be v. welcome.
many thanks

cornelius
Jenna Fox | 3 Feb 2009 01:58
Gravatar

Re: images in db

Make a controller with a get method to retrieve the image, then, have  
some code like this in it, supposing image_data is a string or  
something:

headers['Content-Type'] = 'image/png'
headers['Content-Length'] = image_data.length.to_s
return image_data

On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote:

> hi all
>
> just working on my first camping hack and new to ruby as well.
> i've figured some things out and uploading images into the database,  
> but i'm not sure how to get the data displayed in the browser.
> i'd like to stream it straight from the db, not copy it to the fs  
> first.
> obviously img(:src => file_data) doesn't work.
> any pointers or reading assignments would be v. welcome.
> many thanks
>
> cornelius
> _______________________________________________
> Camping-list mailing list
> Camping-list@...
> http://rubyforge.org/mailman/listinfo/camping-list
Roland Crosby | 3 Feb 2009 02:15

Re: images in db

Well, you could sorta do img(:src => file_data), using the data: URI scheme.

def data_uri(file_data, mime_type="image/png")
  "data:#{mime_type};base64,#{[file_data].pack('m*')}".strip
end

Then you could just do img(:src => data_uri(file_data)), and it should work.

On Mon, Feb 2, 2009 at 6:58 PM, Cornelius Jaeger <cjlists@...> wrote:
> hi all
>
> just working on my first camping hack and new to ruby as well.
> i've figured some things out and uploading images into the database, but i'm
> not sure how to get the data displayed in the browser.
> i'd like to stream it straight from the db, not copy it to the fs first.
> obviously img(:src => file_data) doesn't work.
> any pointers or reading assignments would be v. welcome.
> many thanks
>
> cornelius
> _______________________________________________
> Camping-list mailing list
> Camping-list@...
> http://rubyforge.org/mailman/listinfo/camping-list
>
Jenna Fox | 3 Feb 2009 02:23
Gravatar

Re: images in db

Mmm, indeededly, though data: uri's don't work at all in internet  
explorer, quite the bummer if you care :)

On 03/02/2009, at 12:15 PM, Roland Crosby wrote:

> Well, you could sorta do img(:src => file_data), using the data: URI  
> scheme.
>
> def data_uri(file_data, mime_type="image/png")
>  "data:#{mime_type};base64,#{[file_data].pack('m*')}".strip
> end
>
> Then you could just do img(:src => data_uri(file_data)), and it  
> should work.
>
> On Mon, Feb 2, 2009 at 6:58 PM, Cornelius Jaeger <cjlists@... 
> > wrote:
>> hi all
>>
>> just working on my first camping hack and new to ruby as well.
>> i've figured some things out and uploading images into the  
>> database, but i'm
>> not sure how to get the data displayed in the browser.
>> i'd like to stream it straight from the db, not copy it to the fs  
>> first.
>> obviously img(:src => file_data) doesn't work.
>> any pointers or reading assignments would be v. welcome.
>> many thanks
>>
>> cornelius
(Continue reading)

Cornelius Jaeger | 3 Feb 2009 14:35
Picon

Re: images in db

Hi Jenna, Roland

Thanks for your responses.
How can I get the image inline in the html, rather than downloading it  
to the user?
I'm not at all sure how to use markaby to stream the image data into  
something the img tag will understand.
Many Thanks for helping

Cornelius

On 03.02.2009, at 01:58, Jenna Fox wrote:

> Make a controller with a get method to retrieve the image, then,  
> have some code like this in it, supposing image_data is a string or  
> something:
>
> headers['Content-Type'] = 'image/png'
> headers['Content-Length'] = image_data.length.to_s
> return image_data
>
>
> On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote:
>
>> hi all
>>
>> just working on my first camping hack and new to ruby as well.
>> i've figured some things out and uploading images into the  
>> database, but i'm not sure how to get the data displayed in the  
>> browser.
(Continue reading)

John Beppu | 3 Feb 2009 21:32
Picon
Gravatar

Re: images in db

Roland just showed you how to inline it.

Here's a little article on the technique he's using:

http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

However, as Jenna said, this technique doesn't work in IE.  Her first suggestion is probably the path of least resistance.

--beppu

On Tue, Feb 3, 2009 at 5:35 AM, Cornelius Jaeger <cjlists-PPXtn5OTb+/jCTTTvbEVxA@public.gmane.org> wrote:
Hi Jenna, Roland

Thanks for your responses.
How can I get the image inline in the html, rather than downloading it to the user?
I'm not at all sure how to use markaby to stream the image data into something the img tag will understand.
Many Thanks for helping

Cornelius




On 03.02.2009, at 01:58, Jenna Fox wrote:

Make a controller with a get method to retrieve the image, then, have some code like this in it, supposing image_data is a string or something:

headers['Content-Type'] = 'image/png'
headers['Content-Length'] = image_data.length.to_s
return image_data


On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote:

hi all

just working on my first camping hack and new to ruby as well.
i've figured some things out and uploading images into the database, but i'm not sure how to get the data displayed in the browser.
i'd like to stream it straight from the db, not copy it to the fs first.
obviously img(:src => file_data) doesn't work.
any pointers or reading assignments would be v. welcome.
many thanks

cornelius
_______________________________________________
Camping-list mailing list
Camping-list <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list <at> rubyforge.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list
Cornelius Jaeger | 6 Feb 2009 00:14
Picon

Re: images in db

cheers john

hm, seems strange eh, you'd think this is something that is just possible.
many thanks for the link, i'll work it tonight.
alternatively i'll have to copy the image to the file system after all and serve it from the webserver.

cheers

cornelius

On 03.02.2009, at 21:32, John Beppu wrote:

Roland just showed you how to inline it.

Here's a little article on the technique he's using:

http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

However, as Jenna said, this technique doesn't work in IE.  Her first suggestion is probably the path of least resistance.

--beppu

On Tue, Feb 3, 2009 at 5:35 AM, Cornelius Jaeger <cjlists-PPXtn5OTb+/jCTTTvbEVxA@public.gmane.org> wrote:
Hi Jenna, Roland

Thanks for your responses.
How can I get the image inline in the html, rather than downloading it to the user?
I'm not at all sure how to use markaby to stream the image data into something the img tag will understand.
Many Thanks for helping

Cornelius




On 03.02.2009, at 01:58, Jenna Fox wrote:

Make a controller with a get method to retrieve the image, then, have some code like this in it, supposing image_data is a string or something:

headers['Content-Type'] = 'image/png'
headers['Content-Length'] = image_data.length.to_s
return image_data


On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote:

hi all

just working on my first camping hack and new to ruby as well.
i've figured some things out and uploading images into the database, but i'm not sure how to get the data displayed in the browser.
i'd like to stream it straight from the db, not copy it to the fs first.
obviously img(:src => file_data) doesn't work.
any pointers or reading assignments would be v. welcome.
many thanks

cornelius
_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list
Jenna Fox | 6 Feb 2009 07:39
Gravatar

Re: images in db

Another option, which Rails has a lot of good documentation on, is to create a row in your database which represents the image file, and contains all the related meta data as well as a unique id number, and then just keep the actual images in the filesystem named #.jpeg or some such thing, where the # is the row ID number. This is very common, and good practice for speed as well, because it allows you to eliminate variable width columns in the table in many cases, which gives your database server software an advantage in being able to accurately guess where the next row begins, and skip through without parsing all the data in every row leading up to it.


On 06/02/2009, at 10:14 AM, Cornelius Jaeger wrote:

cheers john

hm, seems strange eh, you'd think this is something that is just possible.
many thanks for the link, i'll work it tonight.
alternatively i'll have to copy the image to the file system after all and serve it from the webserver.

cheers

cornelius

On 03.02.2009, at 21:32, John Beppu wrote:

Roland just showed you how to inline it.

Here's a little article on the technique he's using:

http://jimbojw.com/wiki/index.php?title=Data_URIs_and_Inline_Images

However, as Jenna said, this technique doesn't work in IE.  Her first suggestion is probably the path of least resistance.

--beppu

On Tue, Feb 3, 2009 at 5:35 AM, Cornelius Jaeger <cjlists-PPXtn5OTb+/jCTTTvbEVxA@public.gmane.org> wrote:
Hi Jenna, Roland

Thanks for your responses.
How can I get the image inline in the html, rather than downloading it to the user?
I'm not at all sure how to use markaby to stream the image data into something the img tag will understand.
Many Thanks for helping

Cornelius




On 03.02.2009, at 01:58, Jenna Fox wrote:

Make a controller with a get method to retrieve the image, then, have some code like this in it, supposing image_data is a string or something:

headers['Content-Type'] = 'image/png'
headers['Content-Length'] = image_data.length.to_s
return image_data


On 03/02/2009, at 10:58 AM, Cornelius Jaeger wrote:

hi all

just working on my first camping hack and new to ruby as well.
i've figured some things out and uploading images into the database, but i'm not sure how to get the data displayed in the browser.
i'd like to stream it straight from the db, not copy it to the fs first.
obviously img(:src => file_data) doesn't work.
any pointers or reading assignments would be v. welcome.
many thanks

cornelius
_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/camping-list

_______________________________________________
Camping-list mailing list
Camping-list@...
http://rubyforge.org/mailman/listinfo/camping-list
Julik Tarkhanov | 10 Feb 2009 06:50
Picon

Release?

Hello folks!

Just checking - I understand that Camping 2.0 entered the phase of  
perpetual polishing and will not likely happen,
anytime soon, but would there be a possibility to at least have  
1.5.180 on Robyforge for official installs instead of _why's repo?

I just tried to deploy my blog just with "gem install camping" by  
mistake and been literally plagued by bugs in 1.5.x on forge,  
including the
infamous "query-string-params-totally-mixed-with-path-for-R" problem  
and "all-my-images-appear-blank" problem.

Pretty pretty please?
--

-- 
Julik Tarkhanov
me@...
Magnus Holm | 10 Feb 2009 08:41
Picon
Gravatar

Re: Release?

Yes, we should release 2.0 soon...

Meanwhile you can always download 2.0 using my repo:
gem install camping --source http://gems.judofyr.net/

//Magnus

On 10. feb.. 2009, at 06.50, Julik Tarkhanov  
<julian.tarkhanov@...> wrote:

> Hello folks!
>
> Just checking - I understand that Camping 2.0 entered the phase of  
> perpetual polishing and will not likely happen,
> anytime soon, but would there be a possibility to at least have  
> 1.5.180 on Robyforge for official installs instead of _why's repo?
>
> I just tried to deploy my blog just with "gem install camping" by  
> mistake and been literally plagued by bugs in 1.5.x on forge,  
> including the
> infamous "query-string-params-totally-mixed-with-path-for-R" problem  
> and "all-my-images-appear-blank" problem.
>
> Pretty pretty please?
> -- 
> Julik Tarkhanov
> me@...
>
>
>
>
>
> _______________________________________________
> Camping-list mailing list
> Camping-list@...
> http://rubyforge.org/mailman/listinfo/camping-list

Gmane