I already know that there are no folders in Google Cloud Storage (they are treated as objects), so please take a look at my question and you can understand what I mean. Thank: -)
This is my method for loading an object, and in my particular case I would like to upload a "folder", so a file that ends with a "/" (for example: "newfolder /"), but I get a GoogleJson error in execute () at the end of my code.
[Error]:
Uncaught exception from servlet
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 OK
{
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Required",
"reason" : "required"
}, {
"domain" : "global",
"message" : "Required",
"reason" : "required"
}, {
"domain" : "global",
"message" : "Required",
"reason" : "required"
} ],
"message" : "Required"
}
[my code inside the method]:
StorageObject objectMetadata = null;
String bucketRootName = "defaultbucketname";
String folderAppName = "myfolder";
folderName+="/";
String folderPath = folderAppName + "/" + folderName;
if (useCustomMetadata) {
List<ObjectAccessControl> acl = Lists.newArrayList();
acl.add( new ObjectAccessControl().setEntity("allAuthenticatedUsers").setRole("OWNER"));
objectMetadata = new StorageObject()
.setName(folderPath)
.setAcl(acl)
.setContentDisposition("attachment");
}
Storage.Objects.Insert insertObject = storage.objects().insert(bucketRootName, objectMetadata);
StorageObject metadata = insertObject.execute();
return metadata;
To have a bucket with this path: defaultbucketname / my_folder / FOLDERNAME /
Does anyone know how to solve it?
Thank you very much