<?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>Question Re: Create Stream when uploading attachments in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801676#M4806786</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You shouldn't create the request yourself but use the method &lt;A href="https://sapui5.hana.ondemand.com/#/api/sap.m.upload.UploadSet%23methods/upload" target="_blank"&gt;upload&lt;/A&gt; and the control will trigger it automatically.&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
    <pubDate>Mon, 04 Sep 2023 13:15:52 GMT</pubDate>
    <dc:creator>AlexNecula30</dc:creator>
    <dc:date>2023-09-04T13:15:52Z</dc:date>
    <item>
      <title>Create Stream when uploading attachments</title>
      <link>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaq-p/12801675</link>
      <description>&lt;P&gt;Hi Experts,&lt;/P&gt;
  &lt;P&gt;I am using Uploadset UI5 control for attaching docs. I have "Submit" button to send the attachment to backend.&lt;/P&gt;
  &lt;P&gt;In my controller when i use the below code,&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;var serviceurl = "/sap/opu/odata/sap/ZI_XX_SRV/";&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;var oModel = new sap.ui.model.odata.v2.ODataModel(serviceurl);&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;//Locate base64 content//&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;var base64Index = e.target.result.indexOf(base64_marker) + base64_marker.length;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;// Get base 64 content//&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;var base64 = e.target.result.substring(base64Index);&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;oFileRaw.data = base64;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;var mHeaders = {&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;"slug": oController.byId("UploadSet3").getHeaderFields()[1].getText().split("|")[0],&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;"Content-Type": oController.byId("UploadSet3").getHeaderFields()[2].getText()&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;};&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;oModel.setHeaders(mHeaders);&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;oModel.create(entityset, payLoad, {&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;success: function (oData, response) {&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;debugger;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;alert("yes");&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;},&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;error: function (response) {&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;debugger;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;alert("No");&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;}&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;});&lt;/P&gt;
  &lt;P&gt;It doesnot trigger the backend call and gives error "no hadler for data".&lt;/P&gt;
  &lt;P&gt;So now i am making the oModel change (removing v2) .&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;var oModel = new sap.ui.model.odata.ODataModel(serviceurl);&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Now my odata is triggering, i am getting only slug &amp;amp; content type in headers but my content in payload is not receiving in backend.&lt;/P&gt;
  &lt;P&gt;So now i have commented my code&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;//var mHeaders = {&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;// "slug": oController.byId("UploadSet3").getHeaderFields()[1].getText().split("|")[0],&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;// "Content-Type": oController.byId("UploadSet3").getHeaderFields()[2].getText()&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;// };&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;&lt;/P&gt;
  &lt;P&gt;//oModel.setHeaders(mHeaders);&lt;/P&gt;
  &lt;P&gt;Now in backend i am getting my payload but i am not getting my headers since i have commented.&lt;/P&gt;
  &lt;P&gt;How should i receive both headers(slug &amp;amp; Content type) and payload in a single call? Do i need to use "v2" in my odata service or not?&lt;/P&gt;
  &lt;P&gt;Please help how to resolve this issue&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Gowtham&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 12:25:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaq-p/12801675</guid>
      <dc:creator>GowthamRaja</dc:creator>
      <dc:date>2023-09-04T12:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create Stream when uploading attachments</title>
      <link>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801676#M4806786</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You shouldn't create the request yourself but use the method &lt;A href="https://sapui5.hana.ondemand.com/#/api/sap.m.upload.UploadSet%23methods/upload" target="_blank"&gt;upload&lt;/A&gt; and the control will trigger it automatically.&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 13:15:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801676#M4806786</guid>
      <dc:creator>AlexNecula30</dc:creator>
      <dc:date>2023-09-04T13:15:52Z</dc:date>
    </item>
    <item>
      <title>Re: Create Stream when uploading attachments</title>
      <link>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801677#M4806787</link>
      <description>&lt;P&gt;if we use upload url then it will call the back end automatically I don’t want to do that because end user may attach docs and they may delete that also so if I use uploadurl then the attachments will be uploaded to back end. I don’t want to do that once user finalise the docs to send them I have introduced submit button to trigger back end call&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 13:21:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801677#M4806787</guid>
      <dc:creator>GowthamRaja</dc:creator>
      <dc:date>2023-09-04T13:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create Stream when uploading attachments</title>
      <link>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801678#M4806788</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;gowtham.raja&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;If I understood correctly, your requirement can be handled by setting the property instantUpload = false:&lt;/P&gt;&lt;P&gt;Defines whether the upload process should be triggered as soon as the file is added.&lt;BR /&gt;If set to &lt;CODE&gt;false&lt;/CODE&gt;, no upload is triggered when a file is added.&lt;/P&gt;&lt;P&gt;Then, in your submit button call the upload method.&lt;/P&gt;&lt;P&gt;Alex&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 13:26:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-stream-when-uploading-attachments/qaa-p/12801678#M4806788</guid>
      <dc:creator>AlexNecula30</dc:creator>
      <dc:date>2023-09-04T13:26:27Z</dc:date>
    </item>
  </channel>
</rss>

