Netlify uploadDeployFile doesn't seem to be saving file paths

Site name: https://nifty-meitner-cd6d46.netlify.app

I’ve been experimenting with the netlify API, it seems like the file paths that i use in the uploadDeployFile API call aren’t being saved properly.

For example, here is the result of an uploadDeployFile api call:

id: ‘_next/static/chunks/main-a3a79aff3ff232b41814.js’,
path: ‘_next/static/chunks/main-a3a79aff3ff232b41814.js’,
sha: ‘679be3d4bdda69ae20631f0caed192d2b18efe4c’,
mime_type: ‘application/javascript’,
size: 62760

then, when i use the getSiteFileByPathName api call, i get a 404 not found response:

here is the url that i am using for that call:
https://api.netlify.com/api/v1/sites/54cffbf6-3ecb-4e5f-be7f-ee8fa84f9761/files/_next/static/chunks/main-a3a79aff3ff232b41814.js

Additionally, when i do the listSiteFiles api call, i get this response:
{
“id”: “/main-a3a79aff3ff232b41814.js”,
“path”: “/main-a3a79aff3ff232b41814.js”,
“sha”: “679be3d4bdda69ae20631f0caed192d2b18efe4c”,
“mime_type”: “application/javascript”,
“size”: 62760,
“site_id”: “54cffbf6-3ecb-4e5f-be7f-ee8fa84f9761”,
“deploy_id”: “6104749616b0980a166f75d5”
},

as you can see in the path, the file path does not match the original PUT request when uploading the file.
Am i doing something wrong in the initial request? The request seems correct.

Hi @sviribo,

Sorry to be slow to get back to you, but I cannot reproduce this. Are you sure you’re doing all the steps correctly?

Just to confirm, it would be done something like:

  1. POST to https://api.netlify.com/api/v1/sites/<site-id>/deploys with a JSON body containing the following:
{
    "files": {
        "<file-path>": "<file-SHA1>"
    }
}
  1. You’d get a deploy ID in response. Using that, make a PUT call to https://api.netlify.com/api/v1/deploys/<deploy-id>/files/<file-path>. The headers should be Content-Type: application/octet-stream and the body should be the file itself.

Both these API calls would need the Auth token as a header.

If you’re doing exactly this and still facing an issue, we’d have to investigate this further. But, I personally tried it right before posting and it worked fine. I uploaded a random file to a new website I created for testing and got the response as needed. The file was also accessible in the live website.