Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-07 Thread Devin Asay


On Aug 6, 2007, at 7:06 PM, Mark Wieder wrote:


Devin-

the variable you're loading it into *must* be accessed later in   
another
statement, otherwise the download fails. It's almost like the   
variable

doesn't become a valid variable unless it's accessed later.


...and if you (ahem) declare your local variables you'll find that it
accomplishes the same purpose. And then the why of it all isn't  
quite so

mystifying...


Touché! Almost thou persuadest me to become an Explicit Variables  
Declarer!


Devin

Devin Asay
Humanities Technology and Research Support Center
Brigham Young University

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-07 Thread Terry Judd
Hi Viktoras - the problem with storing images in a stack is that you have to
read the entire stack into memory even if you only access one image (whether
it's in a custom property or not). I've your suggested approach before but
with each image having its own stack to get around the memory issue - I
don't want to go down that path this time though.

Regards,

Terry...

> Hi Terry,
> 
> it is too easy to extract images from sqlite database unless they are
> encrypted somehow. So if you simply store them in the database as blobs,
> they wont be protected from stealing. Alternative way to go is to store
> images in an encrypted stack as custom properties (instead of using a
> folder) and store names of these properties in the database.
> 
> Viktoras
> 
> Terry Judd wrote:
>> Thanks Andre - I've used that sort of approach in the past but the guys
>> providing the content on this project are very protective of their stuff
>> (images) and a 'real' database seems the best option.
>> 
>> Regards,
>> 
>> Terry...
> 

-- 
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA

61-3 8344 0187

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-07 Thread Terry Judd
Hi Ruslan - I'll certainly take a look at Valentina - I've recently heard
good things about it from a couple of developers I know. But I'm a sucker
for robust open source/public domain products like SQLite and I have to say,
apart from the password protection issue it's really easy to use.

Regards,

Terry...

> Hi Terry,
> 
>> Thanks Andre - I've used that sort of approach in the past but the guys
>> providing the content on this project are very protective of their stuff
>> (images) and a 'real' database seems the best option.
> 
> Aha, so this is exactly the case of PROTECTED CONTENT.
> 
> Terry, then try take a look on Valentina because it allow you even ENCRYPT
> your data.
> 

-- 
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA

61-3 8344 0187

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-07 Thread viktoras didziulis

Hi Terry,

it is too easy to extract images from sqlite database unless they are 
encrypted somehow. So if you simply store them in the database as blobs, 
they wont be protected from stealing. Alternative way to go is to store 
images in an encrypted stack as custom properties (instead of using a 
folder) and store names of these properties in the database.


Viktoras

Terry Judd wrote:

Thanks Andre - I've used that sort of approach in the past but the guys
providing the content on this project are very protective of their stuff
(images) and a 'real' database seems the best option.

Regards,

Terry...

  

Terry,
why not keeping the images as external files and putting a field in the
database with the file path? this would lead to databases with less chunk in
it since to use the images you'd have to output them to files anyway.

something like this:

Hard Drive   Image ID Table
  My Database
myImage.jpg <-> Record that match id to file <-->
 field image_id

This is a simple solution where you use a intermediary table to match id's
with files, this way if you change a file name or path, you just need to
update one table entry and not all your database entries that deal with that
file. This makes easy to "reconnect" lost media files if things move around
in the Hard Drive.

I would not put media files inside SQL Databases.

Best
Andre




  


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Ruslan Zasukhin
On 7/8/07 2:32 AM, "Terry Judd" <[EMAIL PROTECTED]> wrote:

Hi Terry,

> Thanks Andre - I've used that sort of approach in the past but the guys
> providing the content on this project are very protective of their stuff
> (images) and a 'real' database seems the best option.

Aha, so this is exactly the case of PROTECTED CONTENT.

Terry, then try take a look on Valentina because it allow you even ENCRYPT
your data.


-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Ruslan Zasukhin
On 6/8/07 8:46 PM, "Andre Garzia" <[EMAIL PROTECTED]> wrote:

Hi Andre,
Hi Terry,

1) If DBMS is REALLY fine to work with BLOBs then no need use any encodings.
The fact you need use encoding (i.e. Convert it into TEXT form),
says that DB cannot keep true BLOBs.

I believe that e.g. Valentina and mySQL do not require encodings.

2) Andre, as you know we have "Valentina for Director", and developers of
Director ARE the most heavy users of MEDIA contents. So we see that really
some of them keep movies, pictures in separate folder, but some developers
choose Valentina EXACTLY BECAUSE it is able effectively store BLOBs inside
of DB files, and even COMPRESS and ENCRYPT them. Encryption is important for
developers who sale CD/DVD with commercial content.


> Terry,
> why not keeping the images as external files and putting a field in the
> database with the file path? this would lead to databases with less chunk in
> it since to use the images you'd have to output them to files anyway.
> 
> something like this:
> 
> Hard Drive   Image ID Table
>   My Database
> myImage.jpg <-> Record that match id to file <-->
>  field image_id
> 
> This is a simple solution where you use a intermediary table to match id's
> with files, this way if you change a file name or path, you just need to
> update one table entry and not all your database entries that deal with that
> file. This makes easy to "reconnect" lost media files if things move around
> in the Hard Drive.
> 
> I would not put media files inside SQL Databases.
> 
> Best
> andre
> 
> On 8/5/07, Terry Judd <[EMAIL PROTECTED]> wrote:
>> 
>> Hi - I'm about to use SQLite to store all the resources for a large ed
>> application I'm about to start building and was wondering whether there
>> was
>> any way to get images into and out of the database without having to
>> base64encode/decode them. It looks like the encoding process adds about
>> 30%
>> to the file size, which for this project could add an extra 100 MB or more
>> to the database file.

-- 
Best regards,

Ruslan Zasukhin
VP Engineering and New Technology
Paradigma Software, Inc

Valentina - Joining Worlds of Information
http://www.paradigmasoft.com

[I feel the need: the need for speed]


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Terry Judd
Another good case for declaring local variables I guess. It all works 'as
advertised' now. Thanks Devin, Mark, Jan (and various contributors to the
list archives).

Cheers,

Terry...

> Devin-
> 
>> the variable you're loading it into *must* be accessed later in  another
>> statement, otherwise the download fails. It's almost like the  variable
>> doesn't become a valid variable unless it's accessed later.
> 
> ...and if you (ahem) declare your local variables you'll find that it
> accomplishes the same purpose. And then the why of it all isn't quite so
> mystifying...
> 
> -- 
>  Mark Wieder
>  [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Mark Wieder
Devin-

> the variable you're loading it into *must* be accessed later in  another 
> statement, otherwise the download fails. It's almost like the  variable 
> doesn't become a valid variable unless it's accessed later.

...and if you (ahem) declare your local variables you'll find that it 
accomplishes the same purpose. And then the why of it all isn't quite so 
mystifying...

-- 
 Mark Wieder
 [EMAIL PROTECTED]



___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Devin Asay


On Aug 6, 2007, at 5:38 PM, Terry Judd wrote:


Hi Jan - I'm already doing something along these lines except with the
base64encode/decode routines thrown in. Getting the image into the  
database
without encoding seems? to work ok but when I pull it out I can  
only get
hold of the first few characters, typically something like 'âPNG'  
and a

couple of returns.


Terry,

I just had a very similar problem that I finally solved after much  
hair pulling. Maybe what I discovered will be of use to you.


I was trying to download audio files (MP3) from a database, and used  
the approach that Jan outlined. But oddly enough, one of my  
revDatabaseColumnNamed function calls would always fail, while  
another, almost identical one, worked. I would get data very similar  
to what you are describing--four characters and nothing else. I  
finally discovered that the function fails consistently, *unless* you  
access the contents of the variable later. So I was doing something  
like this:

(watch for line wraps)

##
put "SELECT audio1,audio2 FROM my_db" into tQuery
put revDatabaseQueryBLOB(gConnection, tQuery) into tCursor
if tCursor is not a number then
  answer error tCursor
else
  put revDatabaseColumnNamed(tCursor,"audio1","tBinData1")
  put revDatabaseColumnNamed(tCursor,"audio2","tBinData2")

  ## then, a few lines later...

  put tBinData1 into ("binfile:" & specialFolderPath("Temporary") &  
"/myfile1.mp3"
  put tAnotherVariable into ("binfile:" & specialFolderPath 
("Temporary") & "/myfile2.mp3"

  revCloseCursor tCursor
end if
##

In other words, I inadvertently was using the incorrect variable when  
trying to save out the audio2 data. It was only after I noticed that  
and changed tAnotherVariable to tBinData2 that the  
revDatabaseColumnNamed function began to work properly. The lesson I  
took from this--and maybe it's the wrong one--is that when using  
revDatabaseColumnNamed to retrieve binary data from a query cursor,  
the variable you're loading it into *must* be accessed later in  
another statement, otherwise the download fails. It's almost like the  
variable doesn't become a valid variable unless it's accessed later.


HTH

Devin


Devin Asay
Humanities Technology and Research Support Center
Brigham Young University

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Terry Judd
Hi Jan - I'm already doing something along these lines except with the
base64encode/decode routines thrown in. Getting the image into the database
without encoding seems? to work ok but when I pull it out I can only get
hold of the first few characters, typically something like 'âPNG' and a
couple of returns.

Regards,

Terry...

> Hi Terry,
> 
> You can try and use the "query with placeholder" style
> to push binary data into the database:
> ##
> put URL("binfile:" & tFilePath) into tBinaryData
> put "INSERT INTO images (:1, :2)" into tQuery
> revExecuteSQL gConnection, tQuery, "tFilePath", "*b" &
> tBinaryData
> put the result into tResult
> if char 1 to 8 of tResult is "revdberr" then
>   answer error tResult
> else
>   -- insert succeeded
> end if
> ##
> 
> If the images are large, you'll want to use the
> revQueryDatabaseBLOB function to get the data out as a
> cursor. Then you can use the function
> 'revDatabaseColumnNamed' to extract the binary data.
> ##
> put "SELECT * FROM images" into tQuery
> put revDatabaseQueryBLOB(gConnection, tQuery) into
> tCursor
> if tCursor is not a number then
>   answer error tCursor
> else
>   put revDatabaseColumnNamed(tCursor,"binData") into
> tBinData
>   -- do what you need to do
>   -- ...
>   -- clean up the cursor afterwards!
>   revCloseCursor tCursor
> end if
> ##
> 
> Base64Encoding is great if you have to move stuff
> accross platforms and technologies; but the above may
> do the trick for you.
> 
> Hope this helped,
> 
> Jan Schenkel.
> 

-- 
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA

61-3 8344 0187

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Terry Judd
Thanks Andre - I've used that sort of approach in the past but the guys
providing the content on this project are very protective of their stuff
(images) and a 'real' database seems the best option.

Regards,

Terry...

> Terry,
> why not keeping the images as external files and putting a field in the
> database with the file path? this would lead to databases with less chunk in
> it since to use the images you'd have to output them to files anyway.
> 
> something like this:
> 
> Hard Drive   Image ID Table
>   My Database
> myImage.jpg <-> Record that match id to file <-->
>  field image_id
> 
> This is a simple solution where you use a intermediary table to match id's
> with files, this way if you change a file name or path, you just need to
> update one table entry and not all your database entries that deal with that
> file. This makes easy to "reconnect" lost media files if things move around
> in the Hard Drive.
> 
> I would not put media files inside SQL Databases.
> 
> Best
> Andre
> 

-- 
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA

61-3 8344 0187

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Jan Schenkel
--- Terry Judd <[EMAIL PROTECTED]> wrote:
> Hi - I'm about to use SQLite to store all the
> resources for a large ed
> application I'm about to start building and was
> wondering whether there was
> any way to get images into and out of the database
> without having to
> base64encode/decode them. It looks like the encoding
> process adds about 30%
> to the file size, which for this project could add
> an extra 100 MB or more
> to the database file.
> 
> Terry...
> 

Hi Terry,

You can try and use the "query with placeholder" style
to push binary data into the database:
##
put URL("binfile:" & tFilePath) into tBinaryData
put "INSERT INTO images (:1, :2)" into tQuery
revExecuteSQL gConnection, tQuery, "tFilePath", "*b" &
tBinaryData
put the result into tResult
if char 1 to 8 of tResult is "revdberr" then
  answer error tResult
else
  -- insert succeeded
end if
##

If the images are large, you'll want to use the
revQueryDatabaseBLOB function to get the data out as a
cursor. Then you can use the function
'revDatabaseColumnNamed' to extract the binary data.
##
put "SELECT * FROM images" into tQuery
put revDatabaseQueryBLOB(gConnection, tQuery) into
tCursor
if tCursor is not a number then
  answer error tCursor
else
  put revDatabaseColumnNamed(tCursor,"binData") into
tBinData
  -- do what you need to do
  -- ...
  -- clean up the cursor afterwards!
  revCloseCursor tCursor
end if
##

Base64Encoding is great if you have to move stuff
accross platforms and technologies; but the above may
do the trick for you.

Hope this helped,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution


=
"As we grow older, we grow both wiser and more foolish at the same time."  (La 
Rochefoucauld)


   

Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-06 Thread Andre Garzia
Terry,
why not keeping the images as external files and putting a field in the
database with the file path? this would lead to databases with less chunk in
it since to use the images you'd have to output them to files anyway.

something like this:

Hard Drive   Image ID Table
  My Database
myImage.jpg <-> Record that match id to file <-->
 field image_id

This is a simple solution where you use a intermediary table to match id's
with files, this way if you change a file name or path, you just need to
update one table entry and not all your database entries that deal with that
file. This makes easy to "reconnect" lost media files if things move around
in the Hard Drive.

I would not put media files inside SQL Databases.

Best
andre

On 8/5/07, Terry Judd <[EMAIL PROTECTED]> wrote:
>
> Hi - I'm about to use SQLite to store all the resources for a large ed
> application I'm about to start building and was wondering whether there
> was
> any way to get images into and out of the database without having to
> base64encode/decode them. It looks like the encoding process adds about
> 30%
> to the file size, which for this project could add an extra 100 MB or more
> to the database file.
>
> Terry...
>
> --
> Dr Terry Judd
> Lecturer in Educational Technology (Design)
> Biomedical Multimedia Unit
> Faculty of Medicine, Dentistry & Health Sciences
> The University of Melbourne
> Parkville VIC 3052
> AUSTRALIA
>
> 61-3 8344 0187
>
> ___
> use-revolution mailing list
> use-revolution@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Inserting images as BLOBs - any way to avoid using base64encode?

2007-08-05 Thread Terry Judd
Hi - I'm about to use SQLite to store all the resources for a large ed
application I'm about to start building and was wondering whether there was
any way to get images into and out of the database without having to
base64encode/decode them. It looks like the encoding process adds about 30%
to the file size, which for this project could add an extra 100 MB or more
to the database file.

Terry...

-- 
Dr Terry Judd
Lecturer in Educational Technology (Design)
Biomedical Multimedia Unit
Faculty of Medicine, Dentistry & Health Sciences
The University of Melbourne
Parkville VIC 3052
AUSTRALIA

61-3 8344 0187

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution