pbms_put_data_cb
Description
pbms_bool pbms_put_data_cb ( PBMS pbms ,const char * table ,char * ref ,size_t blob_size ,PBMS_READ_CALLBACK_FUNC callback ,void * caller_data )
Streams data, via a callback function, to the PBMS BLOB streaming daemon returning a BLOB reference. The BLOB reference can then be inserted into a longblob column of a PBMS enabled table inplace of the actual BLOB data.
Parameters
pbms
A valid PBMS connection handle.
table
The table into which the blob reference will eventually be inserted. If not supplied no table will be associated with the new BLOB until the reference is inserted into a table. Providing the table name here make the BLOB handling on the daemon a bit more efficient.
ref
A pointer to a BLOB reference buffer into which the BLOB reference will be place on successful completion of the function call. The buffer must be atleast MS_BLOB_URL_SIZE bytes.
blob_size
The total size, in bytes, of the data that will be sent.
callback
The callback function through which the data is streamed to the daemon.
caller_data
A pointer to user defined data passed into the callback function.
Return Values

Returns TRUE on success.

Returns FALSE on failure. Use pbms_errno() and pbms_error() to retrieve error details.

Example
size_t file_callback(void *caller_data, char *buffer, size_t size, pbms_bool reset)
{
	int *fh = (int*) caller_data;

	if (reset) {
		lseek(fh, 0, SEEK_SET);
	}
	if (size) {
		size = read(fh, buffer, size);
	}
	return size;
}

main ()
{
	PBMS pbms;
	int fh;
	char blob_ref[MS_BLOB_URL_SIZE];

	pbms_library_init(false);

	pbms = pbms_connect("localhost", 8080, "test");

	 // Send a file using a callback:
	fh = open("myblob.jpg", O_RDONLY, 0000777);

	size = lseek(fh, 0, SEEK_END);
	lseek(fh, 0, SEEK_SET);
	pbms_put_data_cb(pbms, NULL, blob_ref, size, file_callback, &fh);

	printf("Blob reference = \"%s\"\n", (char *) &blob_ref);
	close(fh);

	pbms_close(pbms);
	pbms_library_end();
}		
Related functions
pbms_put_data() pbms_get_data() pbms_get_data_cb()