in storage/src/main/kotlin/Storage.kt [103:118]
fun upload(vararg params: String) { // 2 mandatory and 1 optional args expected: <localFilePath> <bucket> [<blob>]
if (params.size < 2) {
error("Bad input: command 'upload' expects 3 mandatory arguments. \n $usage")
}
val localFilePath = params[0]
val file = Paths.get(localFilePath)
val bucketName = params[1]
val blobName = if (params.size == 2) file.fileName.toString() else params[2]
val bucket = storage.get(bucketName)
?: error("Bucket $bucketName does not exist. You can create a new bucket with the command 'create <bucket>'. \n $usage")
bucket.create(blobName, Files.readAllBytes(file))
println("$blobName was successfully uploaded to bucket $bucketName.")
}