2013-09-04 2 views
1

"gwtuploaded"인 이미지를 앱 엔진에 업로드하고 이미지를 blob로 저장하는 기능을 만들었습니다. 내 문제는 지금 : 업로드 된 이미지보다 작은 이미지로 연결되는 imagesService.getServingUrl(suo)의 URL입니다. 앱 엔진 콘솔에서 blob 뷰어의 이미지를 확인하면 정확한 크기를 가진 것으로 보입니다.앱 엔진 Blobstore/ImageService - 게재 된 이미지의 원래 크기가

왜 다음 코드로 이미지의 크기가 조절 된 버전이 표시됩니까? 어떻게 든 전체 크기의 이미지로 URL을 검색 할 수 있습니까?

내 코드는 다음과 같습니다

public class MyUploadAction extends AppEngineUploadAction{ 

    @Override 
    public String executeAction(HttpServletRequest request, List<FileItem> sessionFiles) throws UploadActionException { 

     String imageUrls = ""; 

     // Image service is needed to get url from blob 
     ImagesService imagesService = ImagesServiceFactory.getImagesService(); 

     // Get a file service -> write the blob 
     FileService fileService = FileServiceFactory.getFileService(); 

     // Iterate over the files and upload each one 
     for(FileItem myFile : sessionFiles){ 

      InputStream imgStream = null; 
      // construct our entity objects 
      Blob imageBlob = null; 

      // Create a new Blob file with mime-type "image/png" 
      AppEngineFile file = null; 

      FileWriteChannel writeChannel = null; 
      try { 
       // get input stream from file 
       imgStream = myFile.getInputStream(); 
       imageBlob = new Blob(IOUtils.toByteArray(imgStream)); 

       // create empty app engine file with mime type of uploaded file e.g.: image/png, image/jpeg 
       file = fileService.createNewBlobFile(myFile.getContentType()); 

       // Open a channel to write to it 
       boolean lock = true; 
       writeChannel = fileService.openWriteChannel(file, lock); 

       // This time we write to the channel directly 
       writeChannel.write(ByteBuffer.wrap(imageBlob.getBytes())); 

      } catch (IOException e) { 
       e.printStackTrace(); 
      }finally{ 
       // Now finalize 
       try { 
        writeChannel.closeFinally(); 
       } catch (IllegalStateException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } catch (IOException e) { 
        // TODO Auto-generated catch block 
        e.printStackTrace(); 
       } 

      } 

      // Get the url from the blob 
      ServingUrlOptions suo = ServingUrlOptions.Builder.withBlobKey(fileService.getBlobKey(file)).secureUrl(true); 
      imageUrls += imagesService.getServingUrl(suo); 
      imageUrls = imageUrls.replaceFirst("0.0.0.0", "127.0.0.1"); 
      System.out.println(imageUrls); 

     } 
     return imageUrls ; 
    } 
} 
+0

에서 직접 이미지 서비스, 단지 출력을 사용하지 않겠습니까? 이미지가 잘못된 치수로 표시된다고 어떻게 판단합니까? 시각적입니까? 브라우저가 이미지의 크기를 조정하여 화면에 완전히 표시합니다. 생성 된 URL에 옵션을 추가하고 있습니까? –

+2

[ImageServices getServingUrl을 사용하여 원본 이미지 가져 오기] 가능한 복제본 (http://stackoverflow.com/questions/13783324/getting-the-original-image-back-with-imageservices-getservingurl) –

답변

1

나는 시도하고 그 이미지 서비스는 1600x1600의 최대 이미지 출력을 가지고 발견했다. 1600 : https://developers.google.com/appengine/docs/java/images/

크기를 요청하지 않아도 적용됩니다.

가 원래 크기의 이미지를 제공하기 위해, 당신은 코드 당신이 당신의 (STABLE) 클러스터에서이 테스트를한다고 가정하면 (예를 들어, Blob 저장소)