Storage storage = null;
try{
FileInputStream credentialsStream = new FileInputStream("JSONFile");
Credentials credentials = GoogleCredentials.fromStream(credentialsStream);
storage = StorageOptions.newBuilder().setCredentials(credentials).build().getService();
}catch(IOException e) {
e.printStackTrace();
}
Acl aclObject = Acl.of(User.ofAllUsers(),Role.OWNER);
List<Acl> aclAccess = new ArrayList<>();
aclAccess.add(aclObject);
//BucketName and User name are Strings.
BlobId blobId = BlobId.of(BUCKET_NAME,USER_NAME+"TeamLogo");
BlobInfo blobInfo = BlobInfo.newBuilder(blobId).setAcl(aclAccess).setContentType("image/jpeg").build();
Blob blob = storage.create(blobInfo);
.png?part=0.1&view=1)
HttpMethod httpMethod = HttpMethod.PUT;
ServiceAccountSigner signer = ServiceAccountCredentials.newBuilder().setClientId(CLIENT_ID).setClientEmail(CLIENT_EMAIL).setPrivateKey(PRIVATEKEY).setPrivateKeyId(PRIVATE_KEY_ID).build()
URL url = blob.signUrl(10,TimeUnit.MINUTES,Storage.SignUrlOption.httpMethod(httpMethod),Storage.SignUrlOption.signWith(signer),Storage.SignUrlOption.withContentType());
return url;
<form action="${signedURL}" method="put" enctype="multipart/form-data">
<label>Enter Your User Name</label><br>
<input type="text" name="UserName" ><br><br>
<label>Enter Your Team Name</label><br>
<input type="text" name="TeamName" ><br><br>
<label>Upload Team Logo</label><br>
<input type="file" name="myFile" required="required"><br><br>
<input type="submit" value="Create Team">
<input type="hidden" name="success_action_redirect" value="http://localhost:8080/register">
</form>
.png?part=0.2&view=1)
I understand that you want to figure out what could be missing in your code, I think StackOverflow Community will be able to provide a better guidance and a probable solution to your inquiries as Google Group is intended for Google Cloud general product discussion purposes only. I would recommend going to Stack Overflow using the proper Cloud Storage tag regarding this issue for further assistance.