2013-04-02 5 views
0

파일 시스템에서 가져온 일부 이미지와 프로젝트 이미지 폴더에있는 이미지가있는 템플릿이 있습니다.이미지가 .doc 파일로 렌더링되지 않음

내 grails 애플리케이션의 images 폴더에서 가져온 템플릿의 이미지는 doc 파일에 완벽하게 표시됩니다.

<img src="${g.resource(dir: 'images', file: 'phone-1.gif', absolute: true)}"/> 

하지만 파일 시스템 (/ 옵션/profileImages 폴더)에서 오는 이미지가 : 나는 이러한 이미지를 렌더링하는 코드 아래 사용하고 있습니다. 코드 아래 사용하면 템플릿 이미지를 렌더링 :

보기 :

<g:img uri="${g.createLink(controller: 'personalDetail', action: 'showUserProfileImage', absolute: true)}"/> 

컨트롤러 :

def showUserProfileImage() { 
    User user = springSecurityService.currentUser as User 
    String profilePicturePath = "${grailsApplication.config.profilePictureDirectoryPath}/${user?.profilePicture?.fileName}" 
    File file = new File(profilePicturePath) 
    def img = file.bytes 
    response.contentType = user?.profilePicture?.mimeType 
    response.outputStream << img 
    response.outputStream.flush() 
} 

브라우저에서 이것은 작업을 잘 보여주는 프로필 이미지뿐만 아니라, Grails 렌더링 플러그인을 사용하여 다운로드 한 PDF에서.

문제는 .doc 형식 파일입니다. 문서를 doc 형식으로 다운로드하면 이미지가 표시되지 않습니다.

스크린 샷 : 내가 잘못 곳

enter image description here

누군가가 말해 주시겠습니까?

또는 다른 방법이 있습니까?

답변

0

Kanwal Nain Singh 솔루션은 서버가 로컬에서 실행되는 경우에만 작동 참조하지만 원격 다시 이미지가없는에서 문서 형식으로 템플릿을 다운로드합니다. 문제는 로컬 시스템의 doc 검색 이미지 (/ opt/profileImages 폴더)입니다. 코드에 따라

는 완벽하게 작동된다

작업 :

def showUserProfileImage() { 
    String profilePicturePath = "${grailsApplication.config.profilePictureDirectoryPath}/${params.id}" 
    File file = new File(profilePicturePath) 
    response.contentType = URLConnection.guessContentTypeFromName(file.getName()) 
    response.outputStream << file.bytes 
    response.outputStream.flush() 
} 

태그 :

<g:img uri="${grailsApplication.config.grails.serverURL}/user/showUserProfileImage/${userImageName}"/> 
1

여기서는 응용 프로그램 컨텍스트에서 이미지 src에 액세스하려고합니다. 소스가 이와 같아야합니다.

<g:img uri="${profilePocturePath}" width="93px" height="100px"/> 

<mvc:resources mapping="/images/**" location="file:/absolute/path/to/image/dir"/>