Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9177989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:26:56+00:00 2026-06-17T17:26:56+00:00

I have an entity that holds the users profile picture. To keep things simple

  • 0

I have an entity that holds the users profile picture. To keep things simple I simply store the serving URL. I am allowing my users to crop their image. To do this I get the image from the serving URL and create a com.google.appengine.api.images.Image; This image doesn’t have a blob key since it was created from a byte array. What is the easiest way to store this image as a blob and get the serving url?

URL url = new URL(currentProfile.getProfilePictureUrl());
InputStream input = url.openStream();
byte[] byteArray = IOUtils.toByteArray(input);
Image newImage = ImagesServiceFactory.makeImage(byteArray);

int imageWidth = newImage.getWidth();
int imageHeight = newImage.getHeight();

ImagesService imagesService = ImagesServiceFactory.getImagesService();
float lx = (float)x/(float)imageWidth;
float ty =  (float)y/(float)imageHeight;
float rx = (float)x2/(float)imageWidth;
float by = (float)y2/(float)imageHeight;
Transform resize = ImagesServiceFactory.makeCrop(lx, ty, rx, by);

Image transImage = imagesService.applyTransform(resize, newImage);

BlobstoreService blobStoreService = BlobstoreServiceFactory.getBlobstoreService();

//This doesn't work because transImage.getBlobKey() is null
ServingUrlOptions options =  ServingUrlOptions.Builder.withBlobKey(transImage.getBlobKey());
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:26:57+00:00Added an answer on June 17, 2026 at 5:26 pm

    You can write data to blobstore programmatically. I use this little snippet:

    private BlobKey saveToBlobstore(String contentType, String imageName, byte[] imageData) throws IOException {
        // Get a file service
        FileService fileService = FileServiceFactory.getFileService();
    
        // Create a new Blob file and set the name to contain ref to UserImage
        AppEngineFile file = fileService.createNewBlobFile(contentType, imageName);
    
        // Open a channel to write to it
        FileWriteChannel writeChannel = fileService.openWriteChannel(file, true);
    
        writeChannel.write(ByteBuffer.wrap(imageData));
        writeChannel.closeFinally();
    
        // return the BlobKey
        return fileService.getBlobKey(file);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Entity that holds the last instance of a Component: @Entity public
I have this DependencyProperty which holds an entity with a property that is a
I have: Task Entity that holds a foreignkey to a Project Entity. In the
When I have an entity that holds a reference to a singular entity I
I have a Core Data project with a sort of master entity that holds
I have this project with an entity A that holds a property b that
I have an entity that has a few relations. I need to clone this
I have an entity that has a collection in it. The collection is a
I have an entity that contains a list of other entities. The list of
Imagine you have an entity that has some relations with other entities and you

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.