# Simulate document upload approved

**URL:** <https://discuss.dwolla.com/t/simulate-document-upload-approved/5716>\
**Category:** API Support\
**Created:** [May 4, 2020, 9:59pm UTC](https://discuss.dwolla.com/t/simulate-document-upload-approved/5716 "2020-05-04T21:59:11Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![Pocket\_Profit](https://sea2.discourse-cdn.com/dwolla/user_avatar/discuss.dwolla.com/pocket_profit/32/3071_2.png) [@Pocket\_Profit](https://discuss.dwolla.com/u/Pocket_Profit)\
**Post date:** [October 14, 2021, 4:51pm UTC](https://discuss.dwolla.com/t/simulate-document-upload-approved/5716/11 "2021-10-14T16:51:12Z")

</div>

> [@Pocket\_Profit](#):
>
> `createDwollaCustomerDocument`

Sorry @Sandeep_Challa, I m just seeing this.  
I do use **multer** with express and all is being done on backend/server side.

the snipet that worked for me is

```auto
const createDwollaCustomerDocument = async (file, customerId, documentType) => {
  try {    
    const customerUrl = `${dwollaApiUrl}/customers/${customerId}`;

    const requestBody = new FormData();
    requestBody.append('file', fs.createReadStream(file.path), {
      filename: file.originalname,
      contentType: file.mimetype,
      knownLength: file.size  
    });
    requestBody.append('documentType', documentType);

  const response = await dwollaClient.post(`${customerUrl}/documents`, requestBody)
  if(!response){
    throw Error("Error uploading document")
  }
  if(response.status = 200)
  {
    let location = response.headers.get('location')
    const lastStringOfLocation = location.substring(location.lastIndexOf("/") + 1, location.length);
    return lastStringOfLocation
  }
  if (response.status = 400){
    return response.body.message
  }
  } catch (error) {
    console.log("Error in customer document:", error)
    return error
  }
}

```

---

_[View the full topic](https://discuss.dwolla.com/t/simulate-document-upload-approved/5716)._
