GcsService (App Engine Client for Google Cloud Storage 0.6 API)


Interface GcsService

  • public interface GcsService
    Allows creating and accessing files in Google Cloud Storage. This class uses the RetryParams that were passed to GcsServiceFactory. This is used for all of the methods provided by this class. So an RetriesExhaustedException means that these have failed. Retry logic is handled internally to this class, because while writing to the GcsOutputChannel a request can span the boundaries of segments written to RawGcsService. As a result a write call could partly succeed, making error recovery at an application level next to impossible. Reading, deleting, and gettingMetadata are all idempotent operations. However for symmetry and convenience the RetryParams are applied to these calls as well.
    • Method Detail

      • openReadChannel

        GcsInputChannel openReadChannel(GcsFilename filename,
                                        long startPosition)
                                 throws IOException
        Note that the implementation may check if the file exists during the call to openReadChannel, or only check it when the first byte is requested. If buffering is desired openPrefetchingReadChannel should be called instead.
      • openPrefetchingReadChannel

        GcsInputChannel openPrefetchingReadChannel(GcsFilename filename,
                                                   long startPosition,
                                                   int blockSizeBytes)
        Same as openReadChannel, but buffers data in memory and prefetches it before it is required to avoid blocking on most read calls. If some data is already available locally (prefetched), but not enough to fill the dst buffer, the returned channel might fill only part of it, to avoid blocking. If no data is available locally, reading from the returned channel will block.
      • getMetadata

        GcsFileMetadata getMetadata(GcsFilename filename)
                             throws IOException
        filename - The name of the file that you wish to read the metadata of.
        The metadata associated with the file, or null if the file does not exist.
        IOException - If for any reason the file can't be read.
      • compose

        void compose(Iterable<String> source,
                     GcsFilename dest)
              throws IOException
        Concatenates a list of existing files into a new file in the same bucket.
        source - the files to compose from
        dest - the composed file
        IOException - if for any reason the file can't be composed
      • copy

        void copy(GcsFilename source,
                  GcsFilename dest)
           throws IOException
        Copies a file to a specified location.
        source - the file to copy from
        dest - the file to copy to
        IOException - if for any reason the file can't be copied
      • update

        void update(GcsFilename source,
                    GcsFileOptions options)
             throws IOException
        Updates a file's metadata with the given options.
        source - the file to update
        options - the updated metadata
        IOException - if for any reason the operation failed
      • list

        ListResult list(String bucket,
                        ListOptions options)
                 throws IOException
        Retrieves a list of objects.
        bucket - the name of the bucket.
        options - optional directions (could be null) on what to include in the result.
        IOException - if list operation failed

Copyright © 2016 Google. All rights reserved.