Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 2 Next »



Convert base64 encoded string to blob


In some cases file data might be represented by base64 encoded strings. The following can be used to convert from base64 encoded file data strings to blob:

persistent object CropQualityPicture {
	blob image;
	string imageStr;
}
// Convert base64 string to blob
cropQualityPicture.image = Blob:fromString(cropQualityPicture.imageStr);





Convert blob to base64 encoded string

Similarly to the above, blobs can also be converted to base64 encoded strings:

// Convert blob to base64 string
cropQualityPicture.imageStr = Blob:toString(cropQualityPicture.image);




Convert base64 encoded string to a wrapped blob

Since blob fields on objects are automatically accompanied by meta attributes that describe mime type, file size and file name, an additional conversion is available where a base64 encoded string can be converted to a built-in object that wraps the blob and includes the above mentioned meta fields:

MezBlobResult blobWrapper = Blob:wrapFromString(cropQualityPicture.imageStr, "image/jpeg", "file_name_str");
// Built-in wrapper object
object MezBlobResult {
	blob blobData;

	// blobData_mtype__, blobData_fname__, blobData_size__, are included by default
}




Download a file for a blob






  • No labels