Rollbase REST Methods setBinaryData, How to send large file?

Posted by Wave Kasipat on 21-Jan-2016 21:02

I used getBinaryData to get file binary from first tenant then used setBinaryData to second tenant (Java Rest webservice).

I can do this method with PDF 300dpi file size 773 KB, But I cannot do with PDF 600dpi file size 1.43 MB (same document).

There is no error and I got status response okay from setBinaryData but no file was created in second tenant.

 

Part of my code.

uri = UriBuilder.fromUri(readConfig.getRBServUrl())
.path("getBinaryData")
.queryParam("sessionId", loginCoop.getSessionId())
.queryParam("output", "json")
.queryParam("objName", "ATM_ApfC")
.queryParam("id", apfCId)
.queryParam("fieldName", "ATM_ApfC_AppFile")
.build();
target = client.target(uri);

response = target.request().get();
responseString = response.readEntity(String.class);
retObject = new JSONObject(responseString);

Form form = new Form();
form.param("contentType", retObject.getString("contentType"));
form.param("fileName", retObject.getString("fileName"));
form.param("value", retObject.getString("fileData"));

uri = UriBuilder.fromUri(readConfig.getRBServUrl())
.path("setBinaryData")
.queryParam("sessionId", loginFSCT.getSessionId())
.queryParam("output", "json")
.queryParam("objName", "ATM_ApfP")
.queryParam("id", apfPId)
.queryParam("fieldName", "ATM_ApfP_AppFile")
.build();
target = client.target(uri);

response = target.request().post(Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE));

 

I suspect that a binary may reach limit when send request,

or there is a limit that I can set in rollbase?

Posted by satyanarayana sunku on 27-Jan-2016 03:04

Hi Kasipat,

There is limit for application servers when you send data in params. So When you send large files better to send  in Mulitipart message as body using POST Method

Below is the code written in Java using apache client 3.1 API.

PostMethod post = new PostMethod(url1);

Part[] p1 = new Part[6];

p1[0] = new StringPart("id", recid);

p1[1] = new StringPart("objName", oName);

p1[2] = new StringPart("fieldName", name);

p1[3] = new StringPart("contentType", "application/pdf");

p1[4] = new StringPart("fileName", "FileImage.pdf");

File f = new File("C:\\Docs\\IoT_Progress.pdf");

FileInputStream fileInputStream = null;

byte[] bFile = new byte[(int) f.length()];

try {

fileInputStream = new FileInputStream(f);

fileInputStream.read(bFile);

fileInputStream.close();

} catch (Exception e) {

e.printStackTrace();

}

String encodeBase64Str = Base64.encodeBase64String(bFile);

System.out.println("lenght is" + encodeBase64Str.length());

// post.addParameter("value",encodeBase64Str);

p1[5] = new StringPart("value", encodeBase64Str);

post.setRequestEntity(new MultipartRequestEntity(p1, post

.getParams()));

httpclient.executeMethod(post);

postResponse = post.getResponseBodyAsString();

try the same in your preferred language.

Thanks

Satya

All Replies

Posted by satyanarayana sunku on 21-Jan-2016 23:49

Hi Wave,

Edit FileUpload Field. In Field Properties we have the drop down to set MaxFile Size . Here we can set max 5 MB.

If We want upload more than 5MB file size we have "MaxFileSizeKB" property in shared.properties file. There we can set it.

Thanks

Satya

Posted by Wave Kasipat on 22-Jan-2016 02:31

i have set MaxFile Size to 24 MB but still got the same problem.

 

Thanks,

Kasipat.

Posted by satyanarayana sunku on 27-Jan-2016 03:04

Hi Kasipat,

There is limit for application servers when you send data in params. So When you send large files better to send  in Mulitipart message as body using POST Method

Below is the code written in Java using apache client 3.1 API.

PostMethod post = new PostMethod(url1);

Part[] p1 = new Part[6];

p1[0] = new StringPart("id", recid);

p1[1] = new StringPart("objName", oName);

p1[2] = new StringPart("fieldName", name);

p1[3] = new StringPart("contentType", "application/pdf");

p1[4] = new StringPart("fileName", "FileImage.pdf");

File f = new File("C:\\Docs\\IoT_Progress.pdf");

FileInputStream fileInputStream = null;

byte[] bFile = new byte[(int) f.length()];

try {

fileInputStream = new FileInputStream(f);

fileInputStream.read(bFile);

fileInputStream.close();

} catch (Exception e) {

e.printStackTrace();

}

String encodeBase64Str = Base64.encodeBase64String(bFile);

System.out.println("lenght is" + encodeBase64Str.length());

// post.addParameter("value",encodeBase64Str);

p1[5] = new StringPart("value", encodeBase64Str);

post.setRequestEntity(new MultipartRequestEntity(p1, post

.getParams()));

httpclient.executeMethod(post);

postResponse = post.getResponseBodyAsString();

try the same in your preferred language.

Thanks

Satya

Posted by Wave Kasipat on 27-Jan-2016 06:15

Hi Satya,

I have tried jersey FormDataMultiPart as Part[] in apache and It Work Perfectly!!

Thank you so much Satya.

Kasipat.

This thread is closed