I'm trying to create new MyImage entitly as listed in How to upload and store an image with google app engine.
Now I'm not using any Form. I have Android app that gets Uri from Gallery :
m_galleryIntent = new Intent();
m_galleryIntent.setType("image/*");
m_galleryIntent.setAction(Intent.ACTION_GET_CONTENT);
m_profileButton.setOnClickListener(new OnClickListener()
{
public void onClick(View v)
{
startActivityForResult(Intent.createChooser(m_galleryIntent, "Select Picture"),1);
}
});
And I'm using the Uri to create a Bitmap.
How can I create a Blob In my client from the Bitmap?
And what jars i'll have to add to my android project?
Is this a proper way to use Blob?
My main goal is to save an image uplodaed from an android in the GAE datastore, Am Using this tools properly or ther is better way?
Thatks.
You have to convert your Bitmap
into a byte[]
and after you can store it in your database as a Blob.
To convert a Bitmap
into a byte[]
, you can use this :
Bitmap yourBitmap;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
yourBitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
byte[] bArray = bos.toByteArray();
I hope it's what you want.
you can use this code :
public static byte[] getBytesFromBitmap(Bitmap bitmap) {
if (bitmap!=null) {
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 70, stream);
return stream.toByteArray();
}
return null;
}
for converting bitmap
to blob.
blob is an binary large object.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With