Java Code Examples for com.google.api.services.storage.model.StorageObject#setName()

The following examples show how to use com.google.api.services.storage.model.StorageObject#setName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeekableGCSStream.java    From dataflow-java with Apache License 2.0 6 votes vote down vote up
private static StorageObject uriToStorageObject(String uri) throws IOException {
  StorageObject object = new StorageObject();
  if (uri.startsWith(GCS_PREFIX)) {
    uri = uri.substring(GCS_PREFIX.length());
  } else {
    throw new IOException("Invalid GCS path (does not start with gs://): " + uri);
  }
  int slashPos = uri.indexOf("/");
  if (slashPos > 0) {
    object.setBucket(uri.substring(0, slashPos));
    object.setName(uri.substring(slashPos + 1));
    LOG.info("uriToStorageObject " + uri + "=" + object.getBucket() + ":" + object.getName());
  } else {
    throw new IOException("Invalid GCS path (does not have bucket/name form): " + uri);
  }
  return object;
}
 
Example 2
Source File: GcsUploaderTests.java    From incubator-heron with Apache License 2.0 4 votes vote down vote up
private StorageObject createStorageObject(String name) {
  final StorageObject storageObject = new StorageObject();
  storageObject.setName(name);
  return storageObject;
}