I am trying to pull a page of user documents on a specific user. I have tried to reach out to Google support to troubleshoot the issue but they did not help in the issue. When I pull this particular user's file list I receive the error :
java.lang.IllegalArgumentException: number field formatted as a JSON string must use the #JsonString annotation [key aperture, field private java.lang.Float com.google.api.services.drive.model.File$ImageMediaMetadata.aperture]
at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:119)
at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:69)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:789)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:438)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:745)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:438)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:745)
at com.google.api.client.json.JsonParser.parseArray(JsonParser.java:610)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:708)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:438)
at com.google.api.client.json.JsonParser.parseValue(JsonParser.java:745)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:358)
at com.google.api.client.json.JsonParser.parse(JsonParser.java:331)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:87)
at com.google.api.client.json.JsonObjectParser.parseAndClose(JsonObjectParser.java:81)
at com.google.api.client.http.HttpResponse.parseAs(HttpResponse.java:459)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
To me this looks like a Java Client Library parsing issue but I would like to bring it to the attention of someone in the Drive team to have them look at it.
The code to produce this error is as following :
Files.List request = service.files().list();
FileList files = request.execute();
Related
I'm using the JSON API Java library to upload objects to Google Cloud Storage. I've figured out how to add the entity allUsers with role READER to get public access, but any other entity/role entries I try to add to my list of ObjectAccessControl produce some generic errors like
com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
"code" : 400,
"errors" : [ {
"domain" : "global",
"message" : "Invalid Value",
"reason" : "invalid"
}
...for each ACL entry I have, except the allUsers READER one which seems to work
I'm not sure what it's complaining about here. I'm trying to reproduce the default permissions I see in the Developers Console, i.e. when I don't specify any ACL on the metadata.
owners-projectId owner,
editors-projectId owner,
viewers-projectId reader,
and user Id owner (I am guessing this is the service account ID)
I'm adding these to the ACL list the same way as the allUsers entity. I've searched for hours trying to find some documentation or similar issues to this, but only found the one regarding allUsers. I've tried escaping these ids, thinking the JSON library might not be doing so for me, but get the same errors.
Here's my relevant Java code:
// Set permissions and content type on StorageObject metadata
StorageObject objectMetadata = new StorageObject();
// set access control
List<ObjectAccessControl> acl = Lists.newArrayList();
acl.add(new ObjectAccessControl().setEntity("allUsers").setRole("READER"));
// this one allows upload to work without error if it is the only access specified,
// but prevents me from modifying publicly available status or editing permissions
// via the developers console (I think this is to be expected)
// attempt to replicating bucket defaults...
// adding any of these will cause the error
acl.add(new ObjectAccessControl().setEntity("owners-projectId").setRole("OWNER"));
acl.add(new ObjectAccessControl().setEntityId("editors-projectId").setRole("OWNER"));
acl.add(new ObjectAccessControl().setEntityId("viewers-projectId").setRole("READER"));
objectMetadata.setAcl(acl);
where projectId is my project ID copied from the Developer's console site.
Finally figured this out.
I first suspected my storage scope of DEVSTORAGE_READ_WRITE was not sufficient, and tried DEVSTORAGE_FULL_CONTROL, but that was not the reason.
Also ignore my use of setEntityId(...) in my original post, although this was something I also tried to no avail.
The problem was simply incorrect syntax in the entity argument. The document you need is this:
https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls
Then you will see that the proper method looks something like:
acl.add(new ObjectAccessControl().setEntity("project-owners-projectId").setRole("OWNER"));
Oddly enough, this did NOT work:
acl.add(new ObjectAccessControl().setProjectTeam(new ProjectTeam().setProjectNumber("projectId").setTeam("owners")).setRole("OWNER"));
I suspect that method of setting the project team entity is a bug in the Java library, but I'm not sure.
The error message for incorrect entities that keeps saying Domain global required, or Domain global invalid value, is simply not very instructive. Setting domain is not required for this case. Also see the discussion at:
What domain is Google Cloud Storage expecting in the ACL definitions when inserting an object?
Hope this helps someone else out!
You can set the access control permission by using "predefinedAcl" the code is as follows.
Storage.Objects.Insert insertObject =client.objects().insert(, ,);
insertObject.setPredefinedAcl("publicRead");
This will work fine
I have written a Servlet where I am reading an image from blobstore, another image from GCS and then after applying a composite on both these images I am storing the composite image back in GCS.
My code works well till here.
After that, when I am trying to get the serving url for the composite image, I am getting an OBJECT_NOT_FOUND.
Just to experiment I manually uploaded a image in GCS and gave all the necessary permissions. Added the serviceaccount as OWNER and gave READ access to All users. And then again I am just trying to get the serving url. Following is my code:-
BlobKey newImageKey = blobstoreService.createGsBlobKey(gcsPath);
//log.severe("GCS PATH: " + gcsPath + " BlobKey: " + newImageKey);
ServingUrlOptions options = ServingUrlOptions.Builder.withBlobKey(newImageKey);
String profilePicLink = imgService.getServingUrl(options);
I also tried the below code:-
ServingUrlOptions options = ServingUrlOptions.Builder.withGoogleStorageFileName(gcsPath);
String profilePicLink = imgService.getServingUrl(options);
And in both the cases this is the error that I am getting:
/controller javax.servlet.ServletException:
java.lang.IllegalArgumentException: OBJECT_NOT_FOUND:
Btw, I have not enable billing as I am using the default bucket with the free quota. This is still in development so the free quota works for me.
OK, so I found out where exactly the exception is happening...
byte[] responseBytes = ApiProxy.makeSyncCall(PACKAGE, "GetUrlBase",
request.build().toByteArray());
and the exception it is throwing is :
ApiProxy.ApplicationException Application Error 8
Enabled billing and tried, still of no use :(
Have been trying to solve this the whole day and tried to search a solution everywhere.
Though this actually does not answer my original question but I have found a workaround. I installed python and gsutil and set the default acl of my bucket to read. Now when I am saving an image file in GCS I am just showing the public url link.
The above can also be achieved if in the GCSFileOptions we add .acl("public-read").
Once the acl is applied by either of the above two methods, in the GCS cloud console you can see the images shared publicly link check box comes as a dash and it says you do not have permission to edit permissions. I was getting confused seeing it, as I was expecting the checkbox to be checked.
But even in the above scenario the publicly shared link will work which is:-
http://storage.googleapis.com/[bucket_name]/[gcs_object_name]
I would still appreciate if someone can explain why the getServingUrl is not not working. Yes, it is still not working after set default acl to read.
Thanks,
Sukalpo.
I could not reproduce this issue by either uploading to Google Cloud storage via the console or via the App Engine GCS Java client. In both cases I could create a public URL for the image
even without specifying any specific permissions.
Do you want to create a production issue request,
https://code.google.com/p/googleappengine/issues/entry?template=Production%20issue
, so we can get more details about your specific case?
What is your gcsPath? I have to use:
"/gs/" + gcsFileName.getBucketName() + "/" + gcsFileName.getObjectName();
Honestly, the only way I've run into this error (and run into this unsolved question) was when I was accidentally using the wrong filename in a difficult to notice way while fetching the BlobKey using Google's APIs.
So, check the obvious things first.
I'm trying o use method CopyIntoItems and add to uploaded file owner property. Field Owner should be type USER. am setting up it like this:
FieldInformation fieldInformationUser = new FieldInformation();
fieldInformationUser.setDisplayName("Owner");
fieldInformationUser.setInternalName("Owner");
fieldInformationUser.setType(FieldType.USER);
fieldInformationUser.setValue("domain//username");
I'm using this library: Sharepoint library link
If TEXT type field is updated in presented above way - it passes, but does't update field at SharePoint server. Problem occurs when i'm using type USER - server returns
Invalid data has been used to update the list item. The field you are trying to update may be read only.
WSDL specifies fieldType.USER as a string field. he question is, how this string should look like... Anyone knows?
You must make sure that the user exists in the users table in SharePoint. It may be that it exists in AD but it hasn't been added to SharePoint yet.
If it were C#, then you would first issue the EnsureUser command:
//C# CSOM code
SPUser user=web.EnsureUser(userName);
listItem[fieldName] = user;
You should search for a similar method in the library you're using
I am programming in android and I am getting some xml data through SOAP which I am placing in a string object. Now I want to get all the id's from and put them in an array. How do I do that ??????
From the code below, i want to get the values 1101, 1103 in an array..... please help
<getAvailableSpotResult>
<garage id=1 name='South Garage' address='100 acme dr' city='san jose' state='ca' zip='95052'>
<floor number='1'>
<spot id='1101' status='available'/>
<spot id='1103' status='available'/>
</floor>
</garage>
</getAvailableSpotResult>
You need to parse the xml to get the required data. If you google, "How to parse xml in java android", you'll get lots of results.
First try and read the official documentation on Parsing XML Data and see the examples.
You can check out other similar questions How to read XML file in android and Read XML file in android. You can also try this tutorial.
Please try to atleast google or see previous answers before asking a question. If there is any specific problem you are facing, everyone would be happy to help.
I have hit a snag that i can not seem to solve. My issue is with retrieving the blob key after the app engine has called my service back. I have tried using blobstoreService.getUploads(request) and i have also tried pulling the blob key from the input stream on the request that is called back to me.
the really strange part is that if i go look into the dashboard i see all of my images in the blob store data view.
I get this error no matter how i try to get the blob keys out :
com.google.apphosting.utils.servlet.ParseBlobUploadFilter doFilter:
Could not parse multipart message: javax.mail.internet.ParseException:
Missing ';'
I am really hung up on this one and i could really use a little help.
EDIT more of the code
the fetch of the blob store url
private String fetchUrl()
{
String url = blobstoreService.createUploadUrl("/BS/returnKey");
return url;
}
snippit of the return code where the error occurs
...
if(inUrl.contains("returnKey"))
{
Map<String, List<BlobKey>> blobs = blobstoreService.getUploads(req);
...
so in my dev environment (the development app server packed in with GAE plugin for eclipse), it works fine, but then after i deploy to the app engine, the same code will not work.
I also tried pulling the data out of the Input stream from the request with teh same results (working on the dev , not on the prod).
thanks to everyone for your help!
The issue was that you can not have spaces in the id of the input on the form. I feel like there should be a more obvious error.
In any event i hope that someone finds this useful!