# API pdf file upload - file format not recognized

**URL:** <https://forum.frame.io/t/api-pdf-file-upload-file-format-not-recognized/78>\
**Category:** Help\
**Tags:** javascript\
**Created:** [November 11, 2021, 9:13am UTC](https://forum.frame.io/t/api-pdf-file-upload-file-format-not-recognized/78 "2021-11-11T09:13:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![animationlandslaget](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/animationlandslaget/32/9_2.png) [@animationlandslaget](https://forum.frame.io/u/animationlandslaget)\
**Post date:** [November 11, 2021, 9:13am UTC](https://forum.frame.io/t/api-pdf-file-upload-file-format-not-recognized/78/1 "2021-11-11T09:13:47Z")

</div>

Hi, I’m uploading pdf files by API, the file gets uploaded but the file corrupted, cannot be opened.  
Can someone please help identify the problem?

This is the code to post the file upload

````auto
const file = await fetch(
    `https://api.frame.io/v2/assets/${folderData.id}/children`,
    {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Authorization: 'Bearer XXXXXX'
      },
      body: JSON.stringify({
        "filesize": 24643,
        "name": "Storyboard preview",
        "filetype": "application/pdf",
        "source": {url: "https://www.ucrhealth.org/wp-content/uploads/2020/04/sample.pdf"},
        "type": "file"
      })
    }
  );
  
  const fileData = await file.json();```

And this is the response I get 

````

{  
“archived\_at”: null,  
“comment\_count”: 0,  
“includes”: null,  
“is\_hls\_required”: false,  
“upload\_failed\_at”: null,  
“is\_360”: false,  
“frames”: 0,  
“is\_session\_watermarked”: false,  
“name”: “Storyboard preview”,  
“archive\_from”: “2021-11-11T09:02:52.496183Z”,  
“allow\_original\_playback”: true,  
“h264\_720”: null,  
“cover”: null,  
“account\_id”: “ef2c228b-4d71-4f13-b532-59dfa7768b8c”,  
“thumb\_orig\_ar\_540”: null,  
“deleted\_at”: null,  
“subtitle\_tracks”: null,  
“versions”: 0,  
“video\_h264\_180”: null,  
“_type": “file”,  
“page\_thumb”: null,  
“copy”: false,  
“user\_permissions”: {  
“can\_download”: true,  
“can\_manage\_devices”: true,  
“can\_modify\_template”: false,  
“can\_public\_share\_presentation”: true,  
“can\_public\_share\_review\_link”: true,  
“can\_share\_downloadable\_presentation”: true,  
“can\_share\_downloadable\_review\_link”: true,  
“can\_share\_unwatermarked\_presentation”: true,  
“can\_share\_unwatermarked\_review\_link”: true,  
“can\_view\_devices”: true  
},  
“transcoded\_at”: null,  
“id”: “384c03d4-2f47-471c-8205-a4189caef08a”,  
“original\_upload”: “[https://frameio-uploads-production.s3-accelerate.amazonaws.com/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-asset\_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-extension=&x-amz-meta-part\_number=1&x-amz-meta-project\_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&x-amz-meta-request\_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-resource\_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource\_type=asset&x-amz-meta-total\_parts=1&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZ5BPIQ3GJVSAXJ5T%2F20211111%2Fus-east-1%2Fs3%2Faws4\_request&X-Amz-Date=20211111T090252Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-acl&X-Amz-Signature=097bc72ef4cd3591e41332d4fb6a68adec4cf0e04350ed2547ac3bb19ef9bb4e](https://frameio-uploads-production.s3-accelerate.amazonaws.com/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-asset_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-extension=&x-amz-meta-part_number=1&x-amz-meta-project_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&x-amz-meta-request_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-resource_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource_type=asset&x-amz-meta-total_parts=1&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZ5BPIQ3GJVSAXJ5T%2F20211111%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211111T090252Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-acl&X-Amz-Signature=097bc72ef4cd3591e41332d4fb6a68adec4cf0e04350ed2547ac3bb19ef9bb4e)”,  
“status”: “created”,  
“required\_transcodes”: null,  
“image\_full”: null,  
“page\_small”: null,  
“waveform”: null,  
“thumb”: null,  
“type”: “file”,  
“upload\_urls”: [  
“[https://frameio-uploads-production.s3-accelerate.amazonaws.com/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-asset\_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-extension=&x-amz-meta-part\_number=1&x-amz-meta-project\_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&x-amz-meta-request\_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-resource\_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource\_type=asset&x-amz-meta-total\_parts=1&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZ5BPIQ3GJVSAXJ5T%2F20211111%2Fus-east-1%2Fs3%2Faws4\_request&X-Amz-Date=20211111T090252Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-acl&X-Amz-Signature=097bc72ef4cd3591e41332d4fb6a68adec4cf0e04350ed2547ac3bb19ef9bb4e](https://frameio-uploads-production.s3-accelerate.amazonaws.com/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-asset_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-extension=&x-amz-meta-part_number=1&x-amz-meta-project_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&x-amz-meta-request_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-resource_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource_type=asset&x-amz-meta-total_parts=1&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAZ5BPIQ3GJVSAXJ5T%2F20211111%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20211111T090252Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-acl&X-Amz-Signature=097bc72ef4cd3591e41332d4fb6a68adec4cf0e04350ed2547ac3bb19ef9bb4e)”  
],  
“label”: “none”,  
“hard\_deleted\_at”: null,  
“cover\_asset\_id”: null,  
“image\_small”: null,  
“uploaded\_at”: “2021-11-11T09:02:52.491003Z”,  
“frame\_cover”: null,  
“webm\_1080\_best”: null,  
“creator\_id”: “051b6776-641e-4dd4-8c90-611c0e92b387”,  
“timecode”: null,  
“updated\_at”: “2021-11-11T09:02:52.496183Z”,  
“filesize”: 0,  
“shared”: false,  
“filetype”: “text/html; charset=UTF-8”,  
“metadata\_flags”: null,  
“frame\_custom”: null,  
“webm\_720”: null,  
“h264\_2160”: null,  
“public\_item\_count”: 0,  
“project\_id”: “f30c7ad6-f425-41e9-ad61-64b389ffe954”,  
“original”: "[https://assets.frame.io/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-resource\_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource\_type=asset&x-amz-meta-request\_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-project\_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&response-content-disposition=attachment%3B+filename%3D"Storyboard+preview"%3B+filename\*%3D"Storyboard+preview"&Expires=1636707772&Signature=EsJ-GZvyAQ~IlFMdU6PzEPlg3yFrPgh~I2vJIN1qS3TrPd9BFsg5Y8ynLW44uCwXFkD99OSqLVMRSgKKWSR5BUwMS17L38Zq76OuX~V-gm0z27BiPA3F8FDO4x1Xf3m-Nb4sfz1HS~p1ZwGwjCLBRrUl~hK8X9QYmaAdrT6aI~zMfxuAVrGKe1hVjBCtHnAq3YN6VzwsobCs1gGt-Y6A-4pjmxNs5WnIDn9udE62ORaVOtT0n3y3R-C74rX-IiPhCxXCC4vSbm48brBbWWRO2~yocOBlob-eAC6DSy4nGBYRI02WvDdQmVG95-uQbu1DqrRJ9RkcS3xXch4SQz3V4g](https://assets.frame.io/uploads/384c03d4-2f47-471c-8205-a4189caef08a/original?x-amz-meta-resource_id=384c03d4-2f47-471c-8205-a4189caef08a&x-amz-meta-resource_type=asset&x-amz-meta-request_id=FrZydy7Ft-6BqeoBAfSH&x-amz-meta-project_id=f30c7ad6-f425-41e9-ad61-64b389ffe954&response-content-disposition=attachment%3B+filename%3D%22Storyboard+preview%22%3B+filename%2A%3D%22Storyboard+preview%22&Expires=1636707772&Signature=EsJ-GZvyAQ~IlFMdU6PzEPlg3yFrPgh~I2vJIN1qS3TrPd9BFsg5Y8ynLW44uCwXFkD99OSqLVMRSgKKWSR5BUwMS17L38Zq76OuX~V-gm0z27BiPA3F8FDO4x1Xf3m-Nb4sfz1HS~p1ZwGwjCLBRrUl~hK8X9QYmaAdrT6aI~zMfxuAVrGKe1hVjBCtHnAq3YN6VzwsobCs1gGt-Y6A-4pjmxNs5WnIDn9udE62ORaVOtT0n3y3R-C74rX-IiPhCxXCC4vSbm48brBbWWRO2~yocOBlob-eAC6DSy4nGBYRI02WvDdQmVG95-uQbu1DqrRJ9RkcS3xXch4SQz3V4g)_\_&Key-Pair-Id=K1XW5DOJMY1ET9”,  
“asset\_type”: null,  
“duration”: null,  
“downloads”: {  
“h264\_1080\_best”: null,  
“h264\_2160”: null,  
“h264\_360”: null,  
“h264\_540”: null,  
“h264\_720”: null,  
“image\_full”: null,  
“image\_high”: null,  
“image\_small”: null  
},  
“upload\_completed\_at”: null,  
“image\_high”: null,  
“h264\_360”: null,  
“view\_count”: 0,  
“resource\_id”: null,  
“item\_count”: 0,  
“transcodes”: null,  
“archive\_status”: null,  
“webm\_360”: null,  
“team\_id”: “4d980fca-2c2c-4822-b642-84de595d0879”,  
“page\_full”: null,  
“rating”: null,  
“properties”: null,  
“fps”: null,  
“drm”: null,  
“page\_high”: null,  
“audio\_tracks”: null,  
“autoversion\_id”: null,  
“h264\_1080\_best”: null,  
“h264\_540”: null,  
“source”: {  
“\_type”: “asset\_source”,  
“external\_id”: null,  
“id”: “b1d50af2-6fea-4c31-9b62-23dd6c3c322e”,  
“provider”: null,  
“url”: “[https://www.ucrhealth.org/wp-content/uploads/2020/04/sample.pdfZ](https://www.ucrhealth.org/wp-content/uploads/2020/04/sample.pdfZ)”  
},  
“description”: null,  
“frame\_thumb”: null,  
“webm\_540”: null,  
“hls\_manifest”: null,  
“thumb\_scrub”: null,  
“inserted\_at”: “2021-11-11T09:02:52.496183Z”,  
“checksums”: null,  
“transcode\_statuses”: null,  
“parent\_id”: “1d4cd910-5108-4460-a985-0564946e4759”,  
“archive\_scheduled\_at”: null,  
“private”: false,  
“thumb\_540”: null,  
“index”: -1  
}

```auto
I've also uploaded two screenshots from frame.io UI, how the file is viewed in the interface

![Screenshot 2021-11-11 at 11.12.25|690x481](upload://5Ut5L06xEGI2eKkJbVj0wex0Vqn.png)
![Screenshot 2021-11-11 at 11.12.35|678x500](upload://yCh7BagVUHZtyi6qwmAAX1KY01O.png)
```

---

<div class="post-metadata">

**Author:** ![jhodges](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/jhodges/32/3_2.png) [@jhodges](https://forum.frame.io/u/jhodges)\
**Post date:** [November 12, 2021, 5:12am UTC](https://forum.frame.io/t/api-pdf-file-upload-file-format-not-recognized/78/2 "2021-11-12T05:12:28Z")

</div>

Hey there!

So I think I know what’s going on here. You’re supplying a `filesize` parameter that is incorrect. You’re specifying `24643` when in reality, the asset you’re linking to is `3028` bytes.

If you drop the `filesize` parameter, our back-end will figure out the correct size for you and you don’t even have to worry about it!

---

<div class="post-metadata">

**Author:** ![animationlandslaget](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.frame.io/animationlandslaget/32/9_2.png) [@animationlandslaget](https://forum.frame.io/u/animationlandslaget)\
**Post date:** [November 12, 2021, 12:57pm UTC](https://forum.frame.io/t/api-pdf-file-upload-file-format-not-recognized/78/3 "2021-11-12T12:57:34Z")

</div>

Ok, got it! Thank you
