After some consideration I have decided to move the BLOB repository from PBXT to MyBS
(§). This has the advantage that any engine that does not have its own BLOB repository (or is otherwise not suitable for storing large amounts of BLOB data) can reference BLOBs in the MyBS BLOB repository.
(§) MyBS stands for "BLOB Streaming for MySQL". The BLOB Streaming engine is a new storage engine for MySQL which allows you to stream media data directly in and out of the database. More info at www.blobstreaming.org.Lets look at an example of this. Assume my standard example table:
CREATE TABLE notes_tab (
n_id int PRIMARY KEY,
n_text longblob
) ENGINE=PBXT;
And assume we have a file called
blob_eg.txt with the contents "This is a BLOB Streaming upload test".
Firstly, I can upload a BLOB to the MyBS BLOB Repository using the HTTP PUT method:
% curl -T blob_eg.txt http://localhost:8080/test/notes_tab
test/1-326-4891cdae-0Here I uploaded a BLOB to the repository and specified the database,
test, and the table,
notes_tab. The URL returned,
test/1-326-4891cdae-0, is the reference to the BLOB in the BLOB repository, returned by MyBS. Note that the BLOB is not yet in the table (to store the BLOB directly in the table, I would have to specify a column and a condition which identifies a particular row in the table).
However, the BLOB is already stored in the database, and I can download as follows:
% curl http://localhost:8080/test/1-326-4891cdae-0
This is a BLOB Streaming upload testSince the BLOB is not yet referenced by a table, the MyBS BLOB repository sets a timer. If the BLOB is not
retained (reference count incremented) within a certain amount of time it is removed from the BLOB repository.
To actually insert the BLOB into the table you just insert the BLOB reference, for example:
mysql> insert notes_tab values (1, "test/1-326-4891cdae-0");On the MySQL server the
notes_tab table engine will call the MyBS engine (using the server-side BLOB Streaming API) and retain the
test/1-326-4891cdae-0 BLOB reference. So I can now download the BLOB by referencing the table, column and row as follows:
% curl http://localhost:8080/test/notes_tab/n_text/n_id=1
This is a BLOB Streaming upload testNote: this example will only work with MyBS 0.5 (
www.blobstreaming.org/download) or later. Coming soon!