First do all required pre requiste as per google doc https://cloud.google.com/appengine/docs/java/googlestorage/ Now see the sample code for a csv file uploader using latest api public String uploadFileUsingGCSClient(String csvDate, String fileName, String dirName,String bucketName) throws IOException { // init the bucket access GcsService gcsService = GcsServiceFactory.createGcsService(RetryParams.getDefaultInstance()); GcsFilename filename = new GcsFilename(bucketName+"/"+dirName, fileName); GcsFileOptions fileOptions = new GcsFileOptions.Builder() .mimeType("application/CSV") .acl("public-read") //.addUserMetadata("myfield1", "my field value") .build(); GcsOutputChannel outputChannel = gcsService.createOrReplace(filename, fileOptions); // write file using this st...
Comments
Post a Comment