Uploading file to nuxeoserver from android

Hi All, While uploading file from Android using “nuxeo-Android-Connector” i'm getting Exception like “Binary request are not supported“. I'm resceiving this exception from defaultsession.java file of nuxeo-android-connector package. i'm using “Nuxeo Android simple client project” Please help me for solving the issue.

0 votes

5 answers

2463 views

ANSWER

Hello,

Could you give more details: which version of the Nuxeo server do you use? Did you build the code from the master branch or did you download an already built APK (if so, from where)?

You seem to use nuxeo-android (Nuxeo Android simple client project) which is a deprecated sample, you should use nuxeo-automation-sample (Nuxeo Android sample client for Nuxeo automation).

Also, do you have some development skills in Android?<br/>Do you aim to customize the sample application, to develop your own application based on the Nuxeo SDK for Android or were you looking for a ready-to-use application?

Regards

03/16/2012

I have downloaded the code from nuxeo site version is 5.4 my aim is to upload any of the file from local SDCard to Nuxeo server. yes I have some development skills in android. I'm looking for customizable sample application.
03/17/2012



Hi Ravi,

did you find your answer? I encounter same issue during picture attachement. I try this code below without success and don't undestand storeAndUpload attributes.

Did you solve it for you?

        Document imageDoc = documentMgr.createDocument(pictureBook, "Picture", "test");
        FileUploader uploader = session.getAdapter(FileUploader.class);
        uploader.storeAndUpload("BID", "1", fb, new AsyncCallback<Serializable>() {

            @Override
            public void onSuccess(String executionId, Serializable data) {
                Log.i(TAG, "success");                    
            }

            @Override
            public void onError(String executionId, Throwable e) {
                Log.i(TAG, "errdroior");                    

            }
        });
0 votes



Doc Url is : http://doc.nuxeo.com/x/GoWE

i'll try to check the build, but the code you need is inside nuxeo-android-connector.

Tiry

0 votes



Hi Tiry, I have include nuxeo-android-connector as reference to my application.

I'm trying to create session with respective credentials as below but it is returning the session as null ,

NuxeoContext nc=NuxeoContextFactory.getNuxeoContext(getApplicationContext());

 AndroidAutomationClient aclient=nc.getNuxeoClient();
 String url=&quot;http://localhost:8080/nuxeo/site/automation&quot;;
 aclient.setBasicAuth(&quot;Username&quot;, &quot;password&quot;);
 Context androidContext=aclient.getAndroidContext();
 SQLStateManager sqlStateManager=aclient.getSqlStateManager();
 BlobStoreManager blobStoreManager=aclient.getBlobStoreManager();
 NuxeoNetworkStatus networkStatus=aclient.getNetworkStatus();
 NuxeoServerConfig serverConfig=aclient.getServerConfig();
 aclient=new AndroidAutomationClient(url,androidContext,sqlStateManager,blobStoreManager,networkStatus,serverConfig);
 Session session1=aclient.getSession(&quot;Username&quot;, &quot;password&quot;);
 Connector client1=aclient.getConnector();

I was doing the above to create object for FileUploader.java class which has constructor of "AndroidAutomationClient" as below public FileUploader(AndroidAutomationClient client) {

    store = client.getBlobStoreManager().getBlobStore(&quot;upload&quot;);
    this.client = client;
}

can you suggest me feasible way to achive…FileUploading… Thank you very much..

03/20/2012

Hi Tiry, I was looking at your posts and I found somebody asked about like below ,actually I have the same problem.

Document doc = (Document) session.newRequest("Document.Create").setInput(docc).set("type", "File").set("name", "uploadfile").set("properties", "dc:title="+filename).execute();

session.newRequest("Blob.Attach").

     setHeader(Constants.HEADER_NX_VOIDOP, &quot;true&quot;)
     .setInput(fb)
     .set(&quot;document&quot;, doc).execute();

in the first line file will be created in the second line the exception will be thrown as "Binary request are not supported".

03/20/2012


Hi,

The BlobWidgetWrapper is part of the nuxeo-android-connector.

There is some documentation about the principles here, but for your specific question the best solution is probably to take a look at the sample code.

=> build nuxeo-android-connector, nuxeo-android-connector-ui and nuxeo-android-sample

you have everything demonstrated inside the sample :

  • view a document
  • edit a document (including blob upload)
  • manage caching

Tiry

0 votes



Hi Tiry, Thanks for the reply,url(http://doc.nuxeo.com/pages/tinyurl.action?urlIdentifier=GoWE—) has pagenot found. Actually I got succeeded only in building nuxeo-android-connector but not nuxeo-android-connector-ui,nuxeo-android-sample using maven other two are i'm not able to fix,actually I'm a .Net guy.. Using the connector i'm able to download file from Nuxeo server.
I was trying to use FileUploader.java from Nuxeo connector but I did not get succeed in creating session using "AndroidAutomationClient".
03/20/2012


Hi,

You should have a look at the sample application. Post (binary upload) is supported, but not via a direct Automation call.

There are mainly 2 reasons for that :

  • Android SDK does not provide native support for Multipart encoding (and I was too lazy to rewrite one)
  • Putting all binary data in the same request may not be very effective from a network point of view ( at least from a mobile device)

That's why in the sample client and application, the binary resources are uploaded separately and simply referenced in the Automation call. This means the cinematic is :

  • you do simple Http Post on /automation/batch/upload for each file
  • you call the automation operation using the batchId used for upload

You can take a look at BlobWidgetWrapper that is used to have a file upload widget.

Hope this helps.

Tiry

0 votes



Hi Thierry Delprat, Thanks for the post, Can you please explain/elaborate or give some reference links/sample to Http post for RESTService or as you explained batch upload or the batchID for Upload. I have FileBlob data of a file ,how can I upload the blob data? I did not get "BlobWidgetWrapper" ,where it is reside in Nuxeoclient code or somewhere over internet?? Can you please help..
03/20/2012


alt text alt text

alt text

0 votes



Hello Julien Carsique, thanks for your reply.. I have enclosed some of the screenshots for your reference, I wanted to upload file from Android to nuxeo server, where i'm not sure where the nuxeo automation client version reside so i have enclosed pom.xml screenshot,and aswell i have enclosed defaultsession.java class file screenshot and nuxeo server from my local pc web view. I'm succeeded in downloading file from nuxeo server from Android while uploading it says "Binary request are not supported". why the exception??is there any problem with this version of nuxeo automation client?? is there any way to upload file with content using NuxeoREST service ,please let me know.
03/17/2012