GcsLib is the libraries of the Google cloud storage, The main purpose is to support the transfer of large files.
support read and write large file
- New extension class of the InputStream and OutputStream. add a new cache layer and is optimized for the blob read and write.
- The contents are pre-cached by chunks when there is read operation. This will eliminate the times of http request and increase the performance greatly.
- resumeable uploads are used for the write operation. Data is buffered firstly and then be uploaded if the buffer size exceed the threshold. This also can eliminate the times of http request and increase the performance greatly.
Config config = new Config("gcp_project_id", "gcp_service_account_json_file");
GcsReqParmas insParams = new GcsReqParmas();
insParams.setBucket("xxxxx.appspot.com");
insParams.setBlob("xxxx-2020-03-25.log");
BlobBufferedIns bbIns = new BlobBufferedIns(insParams);
String line;
while ((line = bbIns.readLine()) != null)
{
System.out.println((line));
Thread.sleep(100);
}
bbIns.close()
GcsReqParmas ousParams = new GcsReqParmas();
ousParams.setBucket("xxxxx.appspot.com");
ousParams.setBlob("xxxx-2020-03-25.log");
BlobBufferedOus bbOus = new BlobBufferedOus(config, outParams);
String outLine = "insert new line here";
bbOus.writeLine(outLine);
bbOus.close();
- The performance depends on the machine and the network.
- [google-cloud-storage] Google Cloud Storage Library for Java .
- no file verification
- Linux
- MacOS
- windows
Copyright (C) 2017 Wesley Wu jie1975.wu@gmail.com
This code is licensed under The General Public License version 3
Your feedbacks are highly appreciated! :)