* 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; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)