When the PBMS engine receives a BLOB the HTTP header tag value pairs are stored with the BLOB as metadata. To restrict which headers are stored as metadata an updatable system table 'pbms_http_fields' is provided in which users can add the names of the headers that are to be treated as metadata. When the BLOB is retrieved from the engine the metadata is sent back along with the BLOB as HTTP headers in the same way that it was received.
The metadata can be accessed from within the database via the 'pbms_matadata' system table or altered by performing inserts, updates, or deletes on the table.
A BLOB alias is a special metadata field that allows you to associate a database wide unique name with the BLOB which can then be used later to retrieve it. If you are familiar with Amazon S3 storage it works in a similar manner where you can think of the database as the S3 bucket and the BLOB alias as the S3 key. To fetch the BLOB back using the alias you use a URL with the format <database>/<alias>. The following is an example using 'curl' to send a BLOB with alias 'MyBLOB' to the PBMS engine and then fetch it back again:
curl -H "PBMS_BLOB_ALIAS:MyBLOB" -d "A BLOB with alias" "http://localhost:8080/test"Returning:~*test/_1-632-4934f86e-0*17curl -D - "http://localhost:8080/test/MyBLOB"Returning:HTTP/1.1 200 OKPBMS_CHECKSUM: A3762FF16159FAB246EBA2BE50F98CF4PBMS_BLOB_SIZE: 17PBMS_LAST_ACCESS: 1236200654PBMS_ACCESS_COUNT: 0PBMS_CREATION_TIME: 1236200654PBMS_BLOB_ALIAS: MyBLOBContent-Length: 17A BLOB with alias
In this example the BLOB has been uploaded to the PBMS engine but not yet referenced so it will be automatically deleted after a preset time.
As you can see several custom headers have been added to the reply:
- PBMS_CHECKSUM is the MD5 checksum of the BLOB data.
- PBMS_BLOB_SIZE is the size of the BLOB data in bytes.
- PBMS_LAST_ACCESS is the last access time of the BLOB in seconds since Jan. 1 1970.
- PBMS_ACCESS_COUNT is the number of times the BLOB has been downloaded.
- PBMS_CREATION_TIME is the creation time of the BLOB in seconds since Jan. 1 1970.
It is also possible to fetch back just the header info with out the BLOB data, example:
curl -H "PBMS_RETURN_INFO_ONLY:yes" -D - "http://localhost:8080/test/MyBLOB"Returning:HTTP/1.1 200 OKPBMS_CHECKSUM: A3762FF16159FAB246EBA2BE50F98CF4PBMS_BLOB_SIZE: 17PBMS_LAST_ACCESS: 1236200654PBMS_ACCESS_COUNT: 0PBMS_CREATION_TIME: 1236200654PBMS_BLOB_ALIAS: MyBLOBContent-Length: 0
The PBMS BLOB metadat enables users to store BLOB specific data with the BLOB and have it returned to them with out having to create a separate database table to store it and then execute separate SQL command to update it and retrieve it when ever they upload or download a BLOB.
The BLOB alias allows users to generate their own names for BLOBs which they can then use to access the BLOB without having to make a call to the database to get the PBMS generated URL.