I have 3GB of size data file to upload into GCP Cloud Storage. I tried with the example in GCP Uploading objects tutorial. But when I'm trying to upload I got the following error.
java.lang.OutOfMemoryError: Required array size too large
I tried as follows,
BlobId blobId = BlobId.of(gcpBucketName, "ft/"+file.getName());
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setContentType("text/plain").build();
Blob blob = storage.get().create(blobInfo, Files.readAllBytes(Paths.get(file.getAbsolutePath())));
return blob.exists();
How may I fix this? Are there any possible way to upload large files using GCP Cloud storage java client?