Examples of GcsFileMetadata


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

  }

  @Override
  public Double getProgress() {
    if (length == -1) {
      GcsFileMetadata metadata = null;
      try {
        metadata = gcsService.getMetadata(file);
      } catch (IOException e) {
        // It is just an estimate so it's probably not worth throwing.
      }
      if (metadata == null) {
        return null;
      }
      length = metadata.getLength();
    }
    if (length == 0f) {
      return null;
    }
    return getBytesRead() / length;
View Full Code Here

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

  @Override
  public List<? extends InputReader<byte[]>> createReaders() {
    GcsService gcsService =
        GcsServiceFactory.createGcsService(MapReduceConstants.GCS_RETRY_PARAMETERS);
    GcsFileMetadata metadata;
    try {
      metadata = gcsService.getMetadata(file);
      if (metadata == null) {
        throw new RuntimeException("File does not exist: " + file);
      }
    } catch (IOException e) {
      throw new RuntimeException("Unable to read file metadata: " + file, e);
    }
    long blobSize = metadata.getLength();
    return split(file, blobSize, shardCount);
  }
View Full Code Here

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

            ByteArrayInputStream bais = new ByteArrayInputStream(BlobstoreServiceFactory.getBlobstoreService().fetchData(new BlobKey(blobKeyString), 0, BlobstoreService.MAX_BLOB_FETCH_SIZE - 1));
            IOUtils.copyStream(bais, outputStream);
            outputStream.write("_123".getBytes());
        } else {
            GcsFilename filename = new GcsFilename("GcsBucket", gsObjectName);
            GcsFileMetadata metadata = service.getMetadata(filename);
            if (metadata == null) {
                throw new IllegalStateException("Null GCS metadata: " + filename);
            }
            mimeType = metadata.getOptions().getMimeType();

            try (InputStream inputStream = Channels.newInputStream(service.openReadChannel(metadata.getFilename(), 0))) {
                IOUtils.copyStream(inputStream, outputStream);
            }
            outputStream.write("_123".getBytes());
        }
View Full Code Here

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

        try (PrintWriter out = new PrintWriter(Channels.newWriter(writeChannel, "UTF8"))) {
            out.println(CONTENT);
            out.flush();
        }

        GcsFileMetadata metaData = gcsService.getMetadata(filename);
        GcsFileOptions option2 = metaData.getOptions();
        try {
            assertEquals(filename, metaData.getFilename());
        } finally {
            gcsService.delete(filename);
        }

        assertEquals("Cache-Control: public, max-age=3600", option2.getCacheControl());
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.