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

  • SEARCH
  • Home
  • 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 9256233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:53:35+00:00 2026-06-18T11:53:35+00:00

im getting this error image corrupt or truncated on FF console when I try

  • 0

im getting this error “image corrupt or truncated” on FF console when I try to display an image stored in my database. I´m using Grails and Hibernate.
I just want to display a user´s profile picture in my gsp page.

My domain class User has an attribute photo defined as byte[]

public class User {

private String userId;
private byte[] photo;
.
.
.

The user.hbm.xml mapping is :

< property name="photo" type="binary" column="PHOTO" not-null="false" />

This collumn is a BLOB on DB.

My gsp:

< div id="user-view-thumbnail-container">
    <fieldset>
      <legend>Photo Upload</legend>
      <g:form action="uploadPhoto" method="post" enctype="multipart/form-data">
        <label for="photo">Photo</label>
        <input type="file" name="photo" id="photo" />
        <input type="submit" class="buttons" value="Upload" />
      </g:form>
    </fieldset>
  <g:if test="${user.photo}">
    <img alt="User Photo"  src="${createLink(controller:'profile', action:'profile_image', id:user.userId)}" />
  </g:if>
</div>

ProfileController:

def uploadPhoto = {       
    def user = userService.getUser(authenticateService.principal()) 
    def f = request.getFile('photo')

    user.setPhoto(f.getBytes())

    if (!user.save()) {
        //doesn´t matter now
        return;
    }

    redirect(action: 'index', model:[user: user])
}

def profile_image = {
    def user = userService.getUser(params.id)

    if (!user) {
        response.sendError(404)
        return;
    }
    response.setContentType(user.photo.contentType())//'image/png', 'image/jpeg', 'image/gif'
    response.setContentLength(user.photo.size())
    OutputStream out = response.getOutputStream();
    out.write(user.photo);
    out.close();
}

FYI: The picture is saved on DB correctly, I can see it, but I can´t show it on my gsp.

Any idea?

Thanks a lot guys,

  • 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-18T11:53:36+00:00Added an answer on June 18, 2026 at 11:53 am

    Use blob type in the mapping :).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to make a shape using variables, I keep getting this error
I installed 11.1.1.5 just now, and am getting this error every time I try
Trying to create a background-image slideshow and am getting this error... This is the
Getting this error when try to add an item to my repositories/context: Collection has
I'm trying to convert an image with imagemagick, but I'm getting this error: convert:
I am getting this error on the error console and can't seem to figure
I am getting this error while implementing SMS sending in android. Attaching the image
InputSream backgroundBitmap; //backgroundBitmap is initialized from asset image.png immutableBitmap = BitmapFactory.decodeStream(backgroundBitmap); getting this error:
Generating an image from a workflow, i'm getting this error.. The type initializer for
I'm getting this error when uploading an image on my hosting. Request for the

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.