Announcement Announcement Module
Collapse
No announcement yet.
trouble rendering an image Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    nevermind this, I was being an idiot

    Comment

    Working...
    X