什么是用于上传到GCS的字节数组格式? [英] What is byte array format for uploading to GCS?

查看:96
本文介绍了什么是用于上传到GCS的字节数组格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码来自此链接,从第85行开始。我是初学者在Java和Google云端存储中。我理解除了第二个参数file之外的所有内容,即字节数组格式。如果我有一个100GB的视频字节数组参数是什么?







The following code is from this link starting on line 85. I'm a beginner in Java and Google Cloud Storage. I understand all of it except for the second parameter, "file", that is to be the byte array format. If I have a video that is 100GB what would the byte array parameter be?



 * Uploads a given file to Google Cloud Storage.
 *
 * @param filePath The desired file path for the file to be uploaded. File path should be absolute path and should include folders, sub-folders, and file name
 * @param file The file to be uploaded in byte array format
 * @return true if the file has been successfully uploaded; false otherwise
 */
public boolean uploadFile(String filePath, byte[] file) {
    try {
        setDefaultStorageCredentials();
        storage.create(BlobInfo.newBuilder(bucketName, filePath).build(),
                new ByteArrayInputStream(file));
        return true;
    } catch (Exception e) {
        return false;
    }
}





我尝试了什么:



我已经使用Part接口和方法getParts()成功上传了一个带有Tomcat服务器的文件。我这样做是为了理解上传和下载程序。 GCS通过使用Blobstore推荐上述代码。



What I have tried:

I have successfully uploaded a file with a Tomcat server using the Part interface and the method getParts(). I did this to understand the upload and download procedure. GCS recommends the above code by using Blobstore.

推荐答案

查看 ByteArrayInputStream(Java Platform SE 7) [ ^ ]文档看来这个参数是一个用于读取的分段缓冲区输入流。您需要提供一定数量的字节缓冲区供上传使用。
Looking at the ByteArrayInputStream (Java Platform SE 7 )[^] documentation it would appear that this parameter is a staging buffer for reading the input stream. You need to provide a buffer of some number of bytes for the upload to use.


这篇关于什么是用于上传到GCS的字节数组格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆