title: how to send binary file to server with Cypress using request
body: <p>I need before the test to upload directly from Cypress API to server an excel-table (without any <em>input[type="file"]</em>, just plain file submission) and then it will be requested back with some other data and used by the test.</p>
  
  <p>So i tried in different ways to make Cypress to use the file by <em>fixture</em>, <em>readfile</em> with different data-encodings, but neigther was working.</p>
  
  <p>As soon as file is received successfully some rest of the code must run.</p>
  
  <pre><code>  before(() =&gt; {
  
    cy.fixture("data/catalog.xlsx", "binary")
      .then(content =&gt; {
  
        cy.wrap(Cypress.Blob.binaryStringToBlob(content, "utf8"))
          .then(blob =&gt; {
  
            const file = new File([blob], "catalog-table", {type: "utf8"});
  
            cy.request("POST", "http://localhost:28080/app/admin/api/catalog/import/xlsx", file)
              .then(res =&gt; {debugger; expect(res.ok).to.be.true})
              .as("fileSend");
  
            cy.wait("@fileSend")
              .then(() =&gt; {some other code to be executed});
          })
      })
  })
  </code></pre>
  
  <p>also tried to add few more headers lines </p>
  
  <pre><code>          cy.request({
              method: "POST",
              url: "http://localhost:28080/app/admin/api/catalog/import/xlsx",
              headers: {
                contentType: false,
                processData: false,
              },
              cache: 'no-cache',
              body: file
            })
  </code></pre>