com.google.appengine.tools.cloudstorage.GcsInputChannel

Here are the examples of the java api class com.google.appengine.tools.cloudstorage.GcsInputChannel taken from open source projects.

1. CloudFileManager#readFileAsJsonObject()

Project: iosched
File: CloudFileManager.java
public JsonObject readFileAsJsonObject(GcsFilename file) throws IOException {
    GcsFileMetadata metadata = gcsService.getMetadata(file);
    if (metadata == null) {
        if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Development) {
            // In the development server, try to fetch files on cloud storage via HTTP
            Logger.getAnonymousLogger().info("fetching " + file.getObjectName() + " at " + Config.CLOUD_STORAGE_BASE_URL + file.getObjectName());
            return RemoteJsonHelper.fetchJsonFromPublicURL(Config.CLOUD_STORAGE_BASE_URL + file.getObjectName());
        }
        return null;
    }
    GcsInputChannel readChannel = null;
    try {
        readChannel = gcsService.openReadChannel(file, 0);
        JsonElement element = new JsonParser().parse(Channels.newReader(readChannel, DEFAULT_CHARSET_NAME));
        return element.getAsJsonObject();
    } finally {
        if (readChannel != null) {
            readChannel.close();
        }
    }
}