API pdf file upload - file format not recognized

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

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”,
“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
],
“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
_&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
},
“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
}

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)

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!

1 Like

Ok, got it! Thank you

1 Like