title: How to upload video/image to Linkedin through API with node?
body: <p>I need to upload an image/video to Linkedin through API. I am using axios and have Content-Type set to multipart/form-data and all my images/videos that need to be uploaded are stored with a url to the file. All files are stored remotely on cloudinary.</p>
  
  <pre><code>let bodyFormData = new FormData();
  bodyFormData.append(
    "fileupload",
    request(file.url).pipe(fs.createWriteStream("video.mp4"))
  );
  axios
    .post("https://api.linkedin.com/media/upload", bodyFormData, {
      headers: {
        Authorization: "Bearer " + account.accessToken,
        "Content-Type": "multipart/form-data"
      }
    })
    .then(linkedinImageResult =&gt; {
  </code></pre>
  
  <p>I am following this documentation here: 
  <a href="https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares#" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/rich-media-shares#</a></p>
  
  <p>One of the common errors I have gotten is: 
  UnhandledPromiseRejectionWarning: TypeError: source.pause is not a function</p>
  
  <p>If I change </p>
  
  <pre><code>request(file.url).pipe(fs.createWriteStream("video.mp4"))
  </code></pre>
  
  <p>to just </p>
  
  <pre><code>file.url
  </code></pre>
  
  <p>I get this error:
  'java.io.IOException: Missing initial multi part boundary'</p>
  
  <p>If I remove </p>
  
  <pre><code>"Content-Type": "multipart/form-data"
  </code></pre>
  
  <p>I get this error:
  "Unable to parse form content"</p>
  
  <p>Note:
  file.url is a url to a cloudinary file, example of file.url: "<a href="https://res.cloudinary.com/dnc1t9z9o/video/upload/v1555527484/mn3tyjcpg1u4anlma2v7.mp4" rel="nofollow noreferrer">https://res.cloudinary.com/dnc1t9z9o/video/upload/v1555527484/mn3tyjcpg1u4anlma2v7.mp4</a>"</p>
  
  <p>Any help is greatly appreciated :) </p>