Deploying via zip file using REST API issues

I am following the walk through on https://www.netlify.com/docs/api/#endpoints to upload a zip file to deploy. I send the following requets to netlify. (my ‘website.zip’ file contains a single ‘index.html’ file). I am in the same directory as zip file when I run the following command.

curl -H "Content-Type: application/zip" \
 -H "Authorization: Bearer xx-xxx-xxx" \
 --data-binary "@website.zip" \
 https://api.netlify.com/api/v1/sites/xxx-xxxx-xxx-xxxx/deploys

It goes through, and returns an object with the status, id, ect. However when I go into the admin UI, I see that my deploy failed. The message says ‘Deploy processing failed after 5 attempts’ and the log is below.

10:11:55 AM: Unpacking archive
10:11:56 AM: Unpacking archive
10:11:56 AM: Unpacking archive
10:11:56 AM: Unpacking archive
10:11:56 AM: Unpacking archive

I also tried an incorrect file location just for testing, and the UI then says ‘empty zip file’. Maybe this is the incorrect way to go about this. My entire mission is to let the user edit the html -> server builds a new zip archive with updated html -> use Netlify API to upload new zip file to production from server. Maybe I should be using the digest method instead? Any help or guidance is greatly appreciated!

Hi Garrett,

The zipfile seems to be corrupt. This is the internal error we receive:

Error extracting zip: Zip end of central directory signature not found

Please make sure you use only a zip program and not 7zip or anything else “fancy”. I would verify a zipfile on linux or dos or OSX (sorry, not sure how to do it on windows) by using something like:

unzip -t file.zip

I seem to be having the exact same problem, I was able to unzip the file without any issues ?

Hi @shaun, Did you verify your file using the method fool mentioned? If not, can you detail what utility you used to check?

Hi Dennis,

Thanks for getting back to me.

I used Debian Linux, regular zip command. Then I tried unzipping it as Fool suggested and I was able to unzip the index.html file just fine, using unzip

Shaun

@shaun can you share a link to one of your deploys that failed? and is the zip archive available somewhere for us to take a look at?

I have the same problem - here is one of my failing deploys: https://app.netlify.com/sites/elegant-mahavira-2feb41/deploys/5e1726c08e0e91bc2e04b1e3

We’ve tried Alpine Linux’s (3.9) zip and p7zip packages and the macOS-integrated archiver utility to no avail.
Commands used:
zip: zip -9 -i@ziplist.txt -r ${DEPLOY_ZIP_NAME} .
p7zip: 7z a -tzip "${DEPLOY_ZIP_NAME}" "@ziplist.txt"

Uploaded via curl: curl -H "Content-Type: application/zip" -H "Authorization: Bearer ${NETLIFY_API_TOKEN}" --data-binary "@${DEPLOY_ZIP_NAME}" https://api.netlify.com/api/v1/sites/${NETLIFY_SITE_ID}/deploys
(as shown in the docs)

We also made sure that the Zip files would decompress properly with different tools and configurations, there didn’t seem to be any corruption or invalid files on our side of things.

The error we see internally is:

too many zip entries

How many files are in the zipfile?

There are 40 files in our current build - are you getting the same error for our previous attempts?

Also, It would be nice to see these errors exposed in the build logs :slight_smile:

1 Like

Hi @michaela,

Do you have your 40 files in a folder inside the zip file or are these files all in the root of the zip file?

Regarding exposing those errors, I’ve added this thread to the enhancement request to improve this and we’ll update here if and when we get that implemented.

1 Like

Hi @Dennis,
there are some in the root of the zip file and nested folders and files, up to three levels deep; usually 1-4 files per folder - no deeply nested zip bomb shenanigans or the like…

Thanks for forwarding my request!

1 Like

Yes, I’m getting this same issue and it seems impossible to debug without seeing the error logs. I’ve probably tried uploading a zip folder 20 different ways at this point and am not sure how to proceed :confused: (also not using anything fancy to zip my folder)

All I see in the deploy logs is:

but it never does anything after that. This user seems to be confused about this too… Here’s my site id in case you’re able to take a look: 93ab841c-95e1-4b7d-bd59-2c31d03cb891

Can’t say exactly what’s wrong with your zipfile, but it causes this error:

Error extracting zip: Is a directory @ rb_sysopen - /tmp/d20200302-10-xkfrkd/

I guess I’d try zipping it differently to see if you can find a way that works better, without any additional details.

Thanks for your message!
… So this is strange. I’m just using Windows 7’s native Send to Zip menu command. It’s the only way I know how to make a zip file on windows… the one I’ve used for at least a decade without issue.

I’ll try to make a .zip file using 7zip.

I’ve tried 7zip to make a .zip file but seeing the same message as before:

image

I’ve tried 7zip to make a .zip file but seeing the same message as before :confused:

Personally, I’m not convinced the way I’m zipping it is actually the problem. After all, I’m using standard zip tools available on Windows. Nothing fancy. So I’m wondering if I’m doing something wrong in Postman - here’s my setup:


So here I’ve uploaded the zip file as a binary file (as recommended by your documentation).

If I upload with the header Content-Type set to application/x-www-form-urlencoded

Then I get:

image

BUT, if I set the Content-Type to application/zip as recommended by your documentation:

Then I get

image

image

Which one of these is right? Neither?

Nitro deploys enabled. Buckle up!

means that this build had a new feature enabled. This indicates the build used a new optimization for how files are uploaded when a deploy is finished.

This feature is enabled for all Netlify sites at this time. It is a new feature and this log entry is there to help us know when it is in use.

Thanks for that clarification @jnisenbom

Unfortunately, I’m still no further along with the Netlify API than I was yesterday. Either I’m doing something really wrong or the ZIP upload endpoint does not work. I’ve tried uploading ZIP files produced by:

I have tried uploading these via:

  • your API
    • via Zip upload
    • via file digest
  • your dashboard

I have done this with:

  • Content-Type set to application/x-www-form-urlencoded
  • Content-Type set to application/zip
  • binary stream
  • trying different filenames

But nothing actually publishes. I’m not given any errors to debug the issues. No time frames within which I can expect these sites to actually publish…or if they are to at all. Almost no feedback about what’s going on. Naturally, this is very frustrating. It’s a bit unexpected, though, considering all of the praise I’ve read on Netlify. Hopefully it’s just something wrong I’m doing. Would be glad to be shown what that is.

I figured it out! What I had been doing, in the pursuit of a simple test, was zipping a single index.html file and uploading that. Instead, what Netlify needs is to first put index.html in a folder, then zip that folder, and finally upload that zipped folder. But because Netlify’s deploy logs do not communicate this error, I went on forcing over 50 variations of the same issue.

I don’t know how common this error is but I wish I hadn’t wasted over 4 hours with it. Especially confusing is to see the this message:
image
which makes me think - oh, the service is work… but then nothing ever happens.

So please consider adding better error logging and testing for this particular upload mishap (where a zipped file rather than a zipped folder is uploaded). Perhaps a warning in the documentation too.

1 Like

Awesome to hear that you’re up and running with the REST API- I know you’ve been wrestling with it for several days now.

We also super appreciate your suggestions and reporting your trial and error process for others who may find this post in the future. I think you’re right that this UI could better reflect the “zipped a file instead of a folder” failure mode- we can’t make any promises about timeline, but I’m going to go ahead and file an issue and we’ll report back here if/when it is resolved. Thanks.

1 Like