As of April 12th, you must go to Progress SupportLink to create new support cases or to access existing cases. Please, bookmark the SupportLink URL and use the new portal to contact the support team.
I am trying to upload a file to Kinvey but I am getting an IllegalArguementException . The code I use to upload the file is from the Java guide(http://devcenter.kinvey.com/java/guides/files#Uploading)
InputStream stream = new ByteArrayInputStream(json.getBytes("UTF-8"));
mKinveyClient.file().uploadBlocking(metadata, stream, new UploaderProgressListener() {
@Override
public void onSuccess(Void result) {
System.out.println("upload success!");
}
@Override
public void onFailure(Throwable error) {
System.out.println("upload progress change!");
}
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
Now when I switch the metadata with a string, everything works fine. The error I am getting is this:
Exception in thread "main" java.lang.IllegalArgumentException: Can not set java.util.List field com.google.api.client.http.HttpHeaders.cacheControl to java.lang.String
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at com.google.api.client.util.FieldInfo.setFieldValue(FieldInfo.java:245)
at com.google.api.client.util.FieldInfo.setValue(FieldInfo.java:206)
at com.google.api.client.util.GenericData.put(GenericData.java:103)
at com.kinvey.java.core.MediaHttpUploader.upload(MediaHttpUploader.java:365)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:347)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:295)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:368)
at com.kinvey.nativejava.File.uploadBlocking(File.java:135)
So I am thinking there is an error in the metadata upload method.
Specifically it seems that the error is related to "metadata.setPublic(true);". When i comment out that line it works.
E
Edward
said
over 9 years ago
Hey,
thanks for reporting this, it is a bug in the library. When setting the public flag to true, the library adds extra headers to the request but there have been recent changes in what GCS is expecting.
I am working through the fix now and will push out a release later this week.
E
Edward
said
over 9 years ago
Hey,
check out v 2.6.12 of the java library, that contains the fix this issue-- try it and let me know how it goes!
http://devcenter.kinvey.com/java/downloads
E
Ebrahim Behbahani
said
over 9 years ago
It works! I can send upload a file to the backend if I set metadata.setPublic(true);. My question is why would I need to? I set the access of files to
access.setGloballyReadable(true);
access.setGloballyWriteable(true);
Doing this allowed other users to access and manipulate the files. So setting the file to public seems redundant. Is there something I am missing?
Ebrahim Behbahani
InputStream stream = new ByteArrayInputStream(json.getBytes("UTF-8"));
mKinveyClient.file().uploadBlocking(metadata, stream, new UploaderProgressListener() {
@Override
public void onSuccess(Void result) {
System.out.println("upload success!");
}
@Override
public void onFailure(Throwable error) {
System.out.println("upload progress change!");
}
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
System.out.println("upload progress change -> " + uploader.getUploadState());
}
});
Now when I switch the metadata with a string, everything works fine. The error I am getting is this:
Exception in thread "main" java.lang.IllegalArgumentException: Can not set java.util.List field com.google.api.client.http.HttpHeaders.cacheControl to java.lang.String
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(Unknown Source)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(Unknown Source)
at java.lang.reflect.Field.set(Unknown Source)
at com.google.api.client.util.FieldInfo.setFieldValue(FieldInfo.java:245)
at com.google.api.client.util.FieldInfo.setValue(FieldInfo.java:206)
at com.google.api.client.util.GenericData.put(GenericData.java:103)
at com.kinvey.java.core.MediaHttpUploader.upload(MediaHttpUploader.java:365)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:347)
at com.kinvey.java.core.AbstractKinveyClientRequest.executeUnparsed(AbstractKinveyClientRequest.java:295)
at com.kinvey.java.core.AbstractKinveyClientRequest.execute(AbstractKinveyClientRequest.java:368)
at com.kinvey.nativejava.File.uploadBlocking(File.java:135)
So I am thinking there is an error in the metadata upload method.