Package com.google.appengine.api.images

Examples of com.google.appengine.api.images.ServingUrlOptions


      sendError(res, "無法正常儲存上傳的檔案");
      return;
    }

    ImagesService imagesService = ImagesServiceFactory.getImagesService();
    ServingUrlOptions servingOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);

    String servingUrl = imagesService.getServingUrl(servingOptions);

    res.setStatus(HttpServletResponse.SC_OK);
    res.setContentType("application/json");
View Full Code Here


        "/gs/" + gcsFilename.getBucketName() + "/" + gcsFilename.getObjectName());

    byte[] imageData = BLOB_STORE.fetchData(blobKey, 0, bytes.length);
    assertArrayEquals(bytes, imageData);

    ServingUrlOptions opts = ServingUrlOptions.Builder.withBlobKey(blobKey);
    opts.imageSize(bytes.length);
    String url = IMAGES_SERVICE.getServingUrl(opts);
    assertTrue(url.length() > 0);
  }
View Full Code Here

        assertEquals(servingUrl1, servingUrl2);
    }

    @Test
    public void servingUrlWithImageSize() throws Exception {
        ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
        String baseUrl = imagesService.getServingUrl(servingUrlOptions);
        String actualUrl = imagesService.getServingUrl(servingUrlOptions.imageSize(32).crop(false));
        String expectedUrl = baseUrl + "=s32";
        assertEquals(expectedUrl, actualUrl);
    }
View Full Code Here

        assertEquals(expectedUrl, actualUrl);
    }

    @Test
    public void servingUrlWithImageSizeAndCrop() throws Exception {
        ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
        String baseUrl = imagesService.getServingUrl(servingUrlOptions);
        String actualUrl = imagesService.getServingUrl(servingUrlOptions.imageSize(32).crop(true));
        String expectedUrl = baseUrl + "=s32-c";
        assertEquals(expectedUrl, actualUrl);
    }
View Full Code Here

        assertEquals(expectedUrl, actualUrl);
    }

    @Test
    public void servingUrlWithSecureFlagFalse() throws Exception {
        ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
        String url = imagesService.getServingUrl(servingUrlOptions.crop(false));
        assertStartsWith("http://", url);

        url = imagesService.getServingUrl(servingUrlOptions.imageSize(32).crop(false).secureUrl(false));
        assertStartsWith("http://", url);
    }
View Full Code Here

    @Test
    public void servingUrlWithSecureFlagTrue() throws Exception {
        assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);

        ServingUrlOptions servingUrlOptions = ServingUrlOptions.Builder.withBlobKey(blobKey);
        String url = imagesService.getServingUrl(servingUrlOptions.secureUrl(true));
        assertStartsWith("https://", url);

        url = imagesService.getServingUrl(servingUrlOptions.imageSize(32).crop(false).secureUrl(true));
        assertStartsWith("https://", url);
    }
View Full Code Here

    @Test
    public void servingUrlWithOptionsWithSecureFlag() throws Exception {
        assumeEnvironment(Environment.APPSPOT, Environment.CAPEDWARF);

        ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(blobKey);

        String url = imagesService.getServingUrl(options);
        assertStartsWith("http://", url);

        url = imagesService.getServingUrl(options.secureUrl(true));
        assertStartsWith("https://", url);
    }
View Full Code Here

TOP

Related Classes of com.google.appengine.api.images.ServingUrlOptions

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.