471,086 Members | 1,187 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

Mapping binary data into the filesystem


Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards
--
Nov 7 '06 #1
7 1460
On Tue, 7 Nov 2006 15:10:49 +0100, Rudi Menter <sp*********@spamgourmet.com>
wrote:
>Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?
PHP can read and write to the filesystem:
http://uk.php.net/manual/en/ref.filesystem.php

It can also communicate with MySQL:
http://uk.php.net/manual/en/ref.mysql.php

--
Andy Hassall :: an**@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 7 '06 #2

Rudi Menter wrote:
Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards
--
See http://fi.php.net/stream-wrapper-register/

Nov 7 '06 #3
Chung Leong write:
Rudi Menter wrote:
>Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards
--

See http://fi.php.net/stream-wrapper-register/

Wow, that's quite interesting,

thx a lot,
Regards
--
Nov 7 '06 #4
Rudi Menter wrote:
Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards
No library I know of. It's not that hard to do. Just have a column in
your database which has the equivalent filename and search for the
appropriate one. i.e. if you were mapping "/members/memberpage.html",
just have a field with that string in it. Then you can easily search
for the string.

Or am I missing something here?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 7 '06 #5
Jerry Stuckle write:
Rudi Menter wrote:
>Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards

No library I know of. It's not that hard to do. Just have a column in
your database which has the equivalent filename and search for the
appropriate one. i.e. if you were mapping "/members/memberpage.html",
just have a field with that string in it. Then you can easily search
for the string.

Or am I missing something here?
For instance, I'd like to
1) convert, say, a file 'explorer.exe' into a string, say, $blobbdata
2) store that in a blob of a database, which is straightforward
3) reread that, from the database into a string, say, $blobbdata
4) convert $blobbdata into a file, say 'explorer.exe', (and execute it)

Sounds easy, no! ;)

Regards
--
Nov 7 '06 #6
Rudi Menter wrote:
Jerry Stuckle write:

>>Rudi Menter wrote:
>>>Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards

No library I know of. It's not that hard to do. Just have a column in
your database which has the equivalent filename and search for the
appropriate one. i.e. if you were mapping "/members/memberpage.html",
just have a field with that string in it. Then you can easily search
for the string.

Or am I missing something here?


For instance, I'd like to
1) convert, say, a file 'explorer.exe' into a string, say, $blobbdata
2) store that in a blob of a database, which is straightforward
3) reread that, from the database into a string, say, $blobbdata
4) convert $blobbdata into a file, say 'explorer.exe', (and execute it)

Sounds easy, no! ;)

Regards
Not hard at all. Just read the file with fread() in binary mode.
INSERT it into your database with an appropriate key (i.e. 'explorer.exe');

When you want it, SELECT the blob from your database into a string. If
it's an executable, you'll need to write it to disk in binary mode, then
execute it with exec().

The main problem you will run into is the file size. The default memory
limit for PHP is 8M. You can change that in your php.ini file if
necessary. Alternatively, you can split the file into blocks and store
it in multiple rows with a sequence number.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 7 '06 #7
Am Tue, 07 Nov 2006 16:05:24 -0500 schrieb Jerry Stuckle:
Rudi Menter wrote:
>Jerry Stuckle write:

>>>Rudi Menter wrote:

Hi, I would like to store binary data (as data-type blob) in
a (MySql-) database, so I require functionality that allows
a mapping from and back into the filesystem. Now, is there
a library for this task that you know of?

Thx,
Regards

No library I know of. It's not that hard to do. Just have a column in
your database which has the equivalent filename and search for the
appropriate one. i.e. if you were mapping "/members/memberpage.html",
just have a field with that string in it. Then you can easily search
for the string.

Or am I missing something here?


For instance, I'd like to
1) convert, say, a file 'explorer.exe' into a string, say, $blobbdata
2) store that in a blob of a database, which is straightforward
3) reread that, from the database into a string, say, $blobbdata
4) convert $blobbdata into a file, say 'explorer.exe', (and execute it)

Sounds easy, no! ;)

Regards

Not hard at all. Just read the file with fread() in binary mode.
INSERT it into your database with an appropriate key (i.e. 'explorer.exe');

When you want it, SELECT the blob from your database into a string. If
it's an executable, you'll need to write it to disk in binary mode, then
execute it with exec().
Aha...
The main problem you will run into is the file size. The default
memory limit for PHP is 8M.
I cee.
You can change that in your php.ini file if necessary.
Alternatively, you can split the file into blocks and store
it in multiple rows with a sequence number.
Thank you!
Regards,
--
Nov 7 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by David Stockwell | last post: by
17 posts views Thread by Arnold | last post: by
4 posts views Thread by Holger Marzen | last post: by
7 posts views Thread by John Salerno | last post: by
23 posts views Thread by ShaneO | last post: by
4 posts views Thread by Dmitry Teslenko | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.