title: How can I get a smartsheet as excel file and put it to cloudinary in PHP?
body: <p>I need your help to get a smartsheet as excel and put it to cloudinary in PHP.
  I use the code bellow.</p>
  <pre><code>/**
   * @param $sheetId
   */
  public function getSheetAsExcel($sheetId)
  {
      $url = self::SMART_SHEET_BASE_URL . '/sheets/' . $sheetId;
      $ch = curl_init();
  
      curl_setopt($ch, CURLOPT_URL, $url);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
  
      $headers = array();
      $headers[] = 'Authorization: Bearer ' . $this-&gt;smartsheetCredentials;
      $headers[] = 'Accept: application/vnd.ms-excel';
  
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
      $result = curl_exec($ch);
      if (curl_errno($ch)) {
          echo 'Error:' . curl_error($ch);
      }
      curl_close($ch);
  
      return $result;
  }
  
  </code></pre>
  <p>A file is created in cloudinary but when I donwload it, I have a wrong format.</p>
  <p><a href="https://i.stack.imgur.com/dNnyM.png" rel="nofollow noreferrer">screenshot of the message shown</a></p>
  <pre><code>$outStream = $this-&gt;smartsheetClient-&gt;getSheetAsExcel($smart_sheet_id);
  $file_name = 'filename.xlsx';
  $cloudinarySignature = (new CloudinayClient())-&gt;getCloudinarySignature();
  
  $temp = tmpfile();
  $path = stream_get_meta_data($temp)['uri'];
  fwrite($temp, file_put_contents($path, $outStream));
  fseek($temp, 0);
  
  $cloudinaryResponse = \Cloudinary\Uploader::upload($path, [
      &quot;public_id&quot; =&gt;  $file_name,
      &quot;resource_type&quot; =&gt; &quot;auto&quot;,
      &quot;signature&quot; =&gt; $cloudinarySignature,
      &quot;version&quot; =&gt; time()
  ]);
  
  fclose($temp);
  
  </code></pre>