public class GcsUtil extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
GcsUtil.GcsUtilFactory
This is a
DefaultValueFactory able to create a GcsUtil using
any transport flags specified on the PipelineOptions. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
bucketExists(GcsPath path)
Returns whether the GCS bucket exists.
|
WritableByteChannel |
create(GcsPath path,
String type)
Creates an object in GCS.
|
List<GcsPath> |
expand(GcsPath gcsPattern)
Expands a pattern into matched paths.
|
long |
fileSize(GcsPath path)
Returns the file size from GCS or throws
FileNotFoundException
if the resource does not exist. |
boolean |
isGcsPatternSupported(String gcsPattern)
Returns true if the given GCS pattern is supported otherwise fails with an
exception.
|
SeekableByteChannel |
open(GcsPath path)
Opens an object in GCS.
|
protected void |
setStorageClient(com.google.api.services.storage.Storage storage) |
public boolean isGcsPatternSupported(String gcsPattern)
protected void setStorageClient(com.google.api.services.storage.Storage storage)
public List<GcsPath> expand(GcsPath gcsPattern) throws IOException
IOExceptionpublic long fileSize(GcsPath path) throws IOException
FileNotFoundException
if the resource does not exist.IOExceptionpublic SeekableByteChannel open(GcsPath path) throws IOException
Returns a SeekableByteChannel that provides access to data in the bucket.
path - the GCS filename to read fromIOExceptionpublic WritableByteChannel create(GcsPath path, String type) throws IOException
Returns a WritableByteChannel that can be used to write data to the object.
path - the GCS file to write totype - the type of object, eg "text/plain".IOExceptionpublic boolean bucketExists(GcsPath path) throws IOException
IOException