title: Ho to upload file to Amazon S3 in node.js from a specific location
body: <p>I'm trying to upload a file to Amazon S3 and the file has in a specific directory.</p>
  
  <p>I tried as follows:</p>
  
  <pre><code>  const parsedEndpoint = await parseString(this, endpoint);
    // post it to rest api
    const url = `${this.appUrl}/${parsedEndpoint}?access_token=${this.auth.access_token}`;
    const options = {
      url,
      json: false,
    };
    const filePath = await this.getResourcePath(`/uploads/p.png`);
    options.formData = {
      filename: `p.png`,
      file: fs.createReadStream(filePath),
    };
    this.lastResponse = await rp.postQ(options);
    expect(this.lastResponse.statusCode).to.equal(200);
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/IrOVe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IrOVe.png" alt="enter image description here"></a></p>