org.opentripplanner.ext.datastore.gs.GsOutFileDataSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.ext.datastore.gs;
import com.google.cloud.storage.BlobId;
import com.google.cloud.storage.BlobInfo;
import com.google.cloud.storage.Storage;
import org.opentripplanner.datastore.DataSource;
import org.opentripplanner.datastore.FileType;
import org.opentripplanner.datastore.file.DirectoryDataSource;
import org.opentripplanner.datastore.file.ZipFileDataSource;
import java.io.OutputStream;
import static java.nio.channels.Channels.newOutputStream;
class GsOutFileDataSource extends AbstractGsDataSource implements DataSource {
private final Storage storage;
/**
* Create a data source wrapper around a file. This wrapper handles GZIP(.gz) compressed files
* as well as normal files. It does not handle directories({@link DirectoryDataSource}) or
* zip-files {@link ZipFileDataSource} witch contain multiple files.
*/
GsOutFileDataSource(Storage storage, BlobId blobId, FileType type) {
super(blobId, type);
this.storage = storage;
}
@Override
public boolean exists() {
return false;
}
@Override
public OutputStream asOutputStream() {
BlobInfo blobInfo = BlobInfo.newBuilder(blobId()).build();
return newOutputStream(storage.writer(blobInfo));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy