Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
AWS Degraded - You may experience Community slowness, timeouts, or trouble accessing: LATEST HERE
cancel
Showing results for 
Search instead for 
Did you mean: 
Attunity_user
Creator
Creator

Using TREST how to upload local csv file to azure blob.

Hi,

 

Could someone please suggest how to upload local file saved in a network drive to Azure blob?  I cannot use tfilefetch because of file is saved in the local drive and upload to Azure blob.  It works in reverse.  Fetching file from blob and dropping it to local drive.  Tried TREST component and it only saves the header and not the file content.  I am not able to make below code work that provided as a solution for TREST.

 

OkHttpClient client = new OkHttpClient();
File sourceFile = new File("C:drive/text.csv");
MediaType mediaType = MediaType.parse("multipart/form-data");
RequestBody body = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "C:drive/text.csv",RequestBody.create(MediaType.parse("/csv"), sourceFile) )
.addFormDataPart("objectName", "project")
.addFormDataPart("objectProperty", "documents")
.addFormDataPart("objectId", context.newProjectId)
.build();
Request request = new Request.Builder()
.url("https://azur")
.post(body)
.addHeader("content-type", "application/csv")
.addHeader("cache-control", "no-cache")
.build();
Response response = client.newCall(request).execute();
String json = response.body().string();
System.out.println(json.toString());

 

Please help.

 

Thanks,

pk

0 Replies