<?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: File Upload in SAP Commerce OCC in CRM and CX Q&amp;A</title>
    <link>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaa-p/12309432#M427661</link>
    <description>&lt;P&gt;Hi Milosz,&lt;/P&gt;&lt;P&gt;Thanks for the proposed solution!&lt;BR /&gt;It works fine now.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Roberto&lt;/P&gt;</description>
    <pubDate>Wed, 17 Mar 2021 16:50:28 GMT</pubDate>
    <dc:creator>roberto_barretorres</dc:creator>
    <dc:date>2021-03-17T16:50:28Z</dc:date>
    <item>
      <title>File Upload in SAP Commerce OCC</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaq-p/12309430</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
  &lt;P&gt;We have a couple of important requirements which the user from the frontend application, Spartacus 3.1, should upload files to our backend system, SAP Commerce Cloud 2011, after trying and doing investigations we couldn't make it work. &lt;BR /&gt;We are trying to implement an endpoint in the OCC API which should accept MultipartFile parameter and then receive the files but we always get the same response "Required request part 'file' is not present". We are also testing it from Postman and same result.&lt;/P&gt;
  &lt;P&gt;Does anyone know how to handle this problem? &lt;/P&gt;
  &lt;P&gt;Thanks in advance!&lt;BR /&gt;Roberto&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 12:08:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaq-p/12309430</guid>
      <dc:creator>roberto_barretorres</dc:creator>
      <dc:date>2021-03-17T12:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: File Upload in SAP Commerce OCC</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaa-p/12309431#M427660</link>
      <description>&lt;P&gt;Hi Roberto,&lt;BR /&gt;&lt;BR /&gt;I was sending file from Spartacus to SAP Commerce platform.&lt;BR /&gt;That is what I needed to do:&lt;BR /&gt;1) angular&lt;BR /&gt;- html:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;input
  type="file"
  name="file"
  id="selectedFile"
  (change)="onFileChanged($event)"
/&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- component ts&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;onFileChanged(event) {
  this.selectedFile = (event.target as HTMLInputElement).files[0];
}
&lt;BR /&gt;// send file to backend
sendFile() {
    let selectedFile: File = this.selectedFile;
    let formData: FormData = new FormData();
    formData.append('selectedFile', selectedFile, selectedFile.name);
    this._myOccService
      .sendFile(formData)
      .subscribe();
  }
}
&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- my occ service&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sendFile(file: FormData): Observable&amp;lt;any&amp;gt; {
  const url = `${this._occEndpoints.getBaseEndpoint()}/files/send`;
  return this._http.post&amp;lt;any&amp;gt;(url, file);
}&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2) backend&lt;BR /&gt;- add config for multipart files in &amp;lt;your-occ-extension-name&amp;gt;-web-spring.xml&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"&amp;gt;
   &amp;lt;property name="favorPathExtension" value="false" /&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"&amp;gt;
   &amp;lt;property name="maxUploadSize" value="209715200" /&amp;gt;
   &amp;lt;property name="maxInMemorySize" value="10485760" /&amp;gt;
&amp;lt;/bean&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;- rest controller&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;@RestController
@RequestMapping(value = "/{baseSiteId}")
public class MyController {

  @PostMapping(path = "/files/send", consumes = "multipart/form-data")
  public void sendFile(@RequestPart("selectedFile") MultipartFile selectedFile) {
                                        // logic...
  }
}&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I think this is all I had to do. Please notice this is just a draft. After that I was able to send file to platform backend. Hope it will work for you too.&lt;/P&gt;&lt;P&gt;Best regards,&lt;BR /&gt;Milosz&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 15:25:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaa-p/12309431#M427660</guid>
      <dc:creator>former_member757157</dc:creator>
      <dc:date>2021-03-17T15:25:26Z</dc:date>
    </item>
    <item>
      <title>Re: File Upload in SAP Commerce OCC</title>
      <link>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaa-p/12309432#M427661</link>
      <description>&lt;P&gt;Hi Milosz,&lt;/P&gt;&lt;P&gt;Thanks for the proposed solution!&lt;BR /&gt;It works fine now.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks and Regards,&lt;/P&gt;&lt;P&gt;Roberto&lt;/P&gt;</description>
      <pubDate>Wed, 17 Mar 2021 16:50:28 GMT</pubDate>
      <guid>https://community.sap.com/t5/crm-and-cx-q-a/file-upload-in-sap-commerce-occ/qaa-p/12309432#M427661</guid>
      <dc:creator>roberto_barretorres</dc:creator>
      <dc:date>2021-03-17T16:50:28Z</dc:date>
    </item>
  </channel>
</rss>

