Examples of GcsFilename


Examples of com.google.appengine.tools.cloudstorage.GcsFilename

  private static final String BUCKET = "bucket";
  private static final String URL_PREFIX = "https://storage.googleapis.com/" + BUCKET + "/";

  @Test
  public void makeUrlShouldCorrectlyGenerateUrlWithoutUploadId() {
    String url = makeUrl(new GcsFilename(BUCKET, "object"), null).toString();
    assertEquals(URL_PREFIX + "object", url);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

  }

  @Test
  public void makeUrlShouldCorrectlyGenerateUrlWithUploadId() {
    Map<String, String> queryStrings = singletonMap("upload_id", "1");
    String url = makeUrl(new GcsFilename(BUCKET, "object"), queryStrings).toString();
    assertEquals(URL_PREFIX + "object?upload_id=1", url);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

  }

  @Test
  public void makeUrlShouldCorrectlyEncodeObjectName() {
    Map<String, String> queryStrings = emptyMap();
    String url = makeUrl(new GcsFilename(BUCKET, "~obj%ect sp{ace>"), queryStrings).toString();
    assertEquals(URL_PREFIX + "~obj%25ect%20sp%7Bace%3E", url);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    queryStrings.put("upload_id", "} 20");
    queryStrings.put("composed", null);
    queryStrings.put("val=ue", "%7D&");
    queryStrings.put("regular", "val");
    queryStrings.put("k e+y", "=v a+lu&e=");
    String url = makeUrl(new GcsFilename(BUCKET, "object"), queryStrings).toString();
    String expected = URL_PREFIX + "object?"
        + "upload_id=%7D+20&"
        + "composed&"
        + "val%3Due=%257D%26&"
        + "regular=val&"
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

      throw new IOException("Compose attempted with too many components. Limit is 32");
    }
    ByteBuffer chunk = ByteBuffer.allocate(1024);
    Token token = beginObjectCreation(dest, GcsFileOptions.getDefaultInstance(), timeoutMillis);
    for (String filename : source) {
      GcsFilename sourceFileName = new GcsFilename(dest.getBucketName(), filename);
      GcsFileMetadata meta = getObjectMetadata(sourceFileName, timeoutMillis);
      if (meta == null) {
        throw new FileNotFoundException(this + ": No such file: " + filename);
      }
      AppEngineFile file = nameToAppEngineFile(sourceFileName);
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

            items.add(new ListItem.Builder().setName(name).setDirectory(true).build());
          }
          continue;
        }
      }
      GcsFilename filename = new GcsFilename(bucket, name);
      GcsFileMetadata metadata = createGcsFileMetadata(entity, filename);
      ListItem listItem = new ListItem.Builder()
          .setName(name)
          .setLength(metadata.getLength())
          .setLastModified(metadata.getLastModified())
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

  @Override
  public ListItemBatch list(String bucket, String prefix, String delimiter, String marker,
      int maxResults,
      long timeoutMillis) throws IOException {
    GcsFilename filename = new GcsFilename(bucket, "");
    Map<String, String> queryStrings = new LinkedHashMap<>();
    if (!Strings.isNullOrEmpty(prefix)) {
      queryStrings.put(PREFIX, prefix);
    }
    if (!Strings.isNullOrEmpty(delimiter)) {
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

   * If the request path is /gcs/Foo/Bar this will be interpreted as
   * a request to read the GCS file named Bar in the bucket Foo.
   */
  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    GcsFilename fileName = getFileName(req);
    if (SERVE_USING_BLOBSTORE_API) {
      BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
      BlobKey blobKey = blobstoreService.createGsBlobKey(
          "/gs/" + fileName.getBucketName() + "/" + fileName.getObjectName());
      blobstoreService.serve(blobKey, resp);
    } else {
      GcsInputChannel readChannel = gcsService.openPrefetchingReadChannel(fileName, 0, BUFFER_SIZE);
      copy(Channels.newInputStream(readChannel), resp.getOutputStream());
    }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

    String[] splits = req.getRequestURI().split("/", 4);
    if (!splits[0].equals("") || !splits[1].equals("gcs")) {
      throw new IllegalArgumentException("The URL is not formed as expected. " +
          "Expecting /gcs/<bucket>/<object>");
    }
    return new GcsFilename(splits[2], splits[3]);
  }
View Full Code Here

Examples of com.google.appengine.tools.cloudstorage.GcsFilename

  @Override
  public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, world from java");
    GcsService gcsService = GcsServiceFactory.createGcsService();
    GcsFilename filename = new GcsFilename(BUCKETNAME, FILENAME);
    GcsFileOptions options = new GcsFileOptions.Builder()
        .mimeType("text/html")
        .acl("public-read")
        .addUserMetadata("myfield1", "my field value")
        .build();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.