Results 1 to 2 of 2

Thread: trouble rendering an image

  1. #1
    Join Date
    Nov 2007
    Posts
    420

    Default trouble rendering an image

    got a weird problem I am hoping someone can answer. I got a simple domain class
    Code:
    class Photo {
    	byte[] file	
    	String contentType
    	
            static belongsTo = Listing
    	static mapWith = "mongo"
            static constraints = {
    		file(nullable:true, maxSize:1000000)
    		contentType(nullable:false)
    	}
    }
    and controller to load/render

    Code:
    class PhotoController {
    	def photoService
            def propertyPhoto() { 
    		def photo = Photo.get(params.id)
    		byte[] file = photo?.file		
    		response.setContentType(photo?.contentType)
    		response.setContentLength(file?.length)
    		response.outputStream << scaled
    	}
    and in the GSP

    Code:
    <div id="slider">
        <ul>
          <g:each in="${listing?.photos }" var="photo" >
               <li><img src="${createLink(controller:'photo', action:'propertyPhoto', id:photo.id)}" alt="Property Photo" /></li>
           </g:each>								
        </ul>
    </div>
    When the page renders I am getting an error:

    Code:
    Resource interpreted as image but transferred with MIME type text/html.
    Funny thing is it works locally but is giving me this error when I deploy it (cloudfoundry) but I am also getting the same error locally on IE (works on Chrome). If I access the photo directly by hitting the photo controller /photo/propertyPhoto/[id] the content type is correct image/jpeg and it correctly renders itself in the browser.

    Any help is greatly appreciated.

  2. #2
    Join Date
    Nov 2007
    Posts
    420

    Default

    nevermind this, I was being an idiot

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •