<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using TREST how to upload local csv file to azure blob. in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Using-TREST-how-to-upload-local-csv-file-to-azure-blob/m-p/2312448#M83397</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please suggest how to upload local file saved in a network drive to Azure blob?&amp;nbsp; I cannot use tfilefetch because of file is saved in the local drive and upload to Azure blob.&amp;nbsp; It works in reverse.&amp;nbsp; Fetching file from blob and dropping it to local drive.&amp;nbsp; Tried TREST component and it only saves the header and not the file content.&amp;nbsp; I am not able to make below code work that provided as a solution for TREST.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OkHttpClient client = new OkHttpClient();&lt;BR /&gt;File sourceFile = new File("C:drive/text.csv");&lt;BR /&gt;MediaType mediaType = MediaType.parse("multipart/form-data");&lt;BR /&gt;RequestBody body = new MultipartBody.Builder()&lt;BR /&gt;.setType(MultipartBody.FORM)&lt;BR /&gt;.addFormDataPart("file", "&lt;SPAN&gt;C:drive/text&lt;/SPAN&gt;&lt;SPAN&gt;.csv&lt;/SPAN&gt;",RequestBody.create(MediaType.parse("/csv"), sourceFile) )&lt;BR /&gt;.addFormDataPart("objectName", "project")&lt;BR /&gt;.addFormDataPart("objectProperty", "documents")&lt;BR /&gt;.addFormDataPart("objectId", context.newProjectId)&lt;BR /&gt;.build();&lt;BR /&gt;Request request = new Request.Builder()&lt;BR /&gt;.url("https://azur")&lt;BR /&gt;.post(body)&lt;BR /&gt;.addHeader("content-type", "application/csv")&lt;BR /&gt;.addHeader("cache-control", "no-cache")&lt;BR /&gt;.build();&lt;BR /&gt;Response response = client.newCall(request).execute();&lt;BR /&gt;String json = response.body().string();&lt;BR /&gt;System.out.println(json.toString());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;</description>
    <pubDate>Mon, 20 Aug 2018 17:06:35 GMT</pubDate>
    <dc:creator>Attunity_user</dc:creator>
    <dc:date>2018-08-20T17:06:35Z</dc:date>
    <item>
      <title>Using TREST how to upload local csv file to azure blob.</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Using-TREST-how-to-upload-local-csv-file-to-azure-blob/m-p/2312448#M83397</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could someone please suggest how to upload local file saved in a network drive to Azure blob?&amp;nbsp; I cannot use tfilefetch because of file is saved in the local drive and upload to Azure blob.&amp;nbsp; It works in reverse.&amp;nbsp; Fetching file from blob and dropping it to local drive.&amp;nbsp; Tried TREST component and it only saves the header and not the file content.&amp;nbsp; I am not able to make below code work that provided as a solution for TREST.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OkHttpClient client = new OkHttpClient();&lt;BR /&gt;File sourceFile = new File("C:drive/text.csv");&lt;BR /&gt;MediaType mediaType = MediaType.parse("multipart/form-data");&lt;BR /&gt;RequestBody body = new MultipartBody.Builder()&lt;BR /&gt;.setType(MultipartBody.FORM)&lt;BR /&gt;.addFormDataPart("file", "&lt;SPAN&gt;C:drive/text&lt;/SPAN&gt;&lt;SPAN&gt;.csv&lt;/SPAN&gt;",RequestBody.create(MediaType.parse("/csv"), sourceFile) )&lt;BR /&gt;.addFormDataPart("objectName", "project")&lt;BR /&gt;.addFormDataPart("objectProperty", "documents")&lt;BR /&gt;.addFormDataPart("objectId", context.newProjectId)&lt;BR /&gt;.build();&lt;BR /&gt;Request request = new Request.Builder()&lt;BR /&gt;.url("https://azur")&lt;BR /&gt;.post(body)&lt;BR /&gt;.addHeader("content-type", "application/csv")&lt;BR /&gt;.addHeader("cache-control", "no-cache")&lt;BR /&gt;.build();&lt;BR /&gt;Response response = client.newCall(request).execute();&lt;BR /&gt;String json = response.body().string();&lt;BR /&gt;System.out.println(json.toString());&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;pk&lt;/P&gt;</description>
      <pubDate>Mon, 20 Aug 2018 17:06:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Using-TREST-how-to-upload-local-csv-file-to-azure-blob/m-p/2312448#M83397</guid>
      <dc:creator>Attunity_user</dc:creator>
      <dc:date>2018-08-20T17:06:35Z</dc:date>
    </item>
  </channel>
</rss>

