Cloudflare Pages -> Direct Uploads -> ZIP file with directories

When I upload a ZIP file to Cloudflare Pages it doesn’t extract the subdirectories in it. The display of the total amount of files in the ZIP file is correct.

When I upload a directory (with the same subdirectories) everything goes ok.

See: Introducing Direct Uploads for Cloudflare Pages

You need to compress the contents of the directory, and not the directory itself.

If doing this on the command line you want to do this:

% cd webroot
% zip --quiet -r ../direct-upload-contents.zip ./
% unzip -l ../direct-upload-contents.zip
Archive:  ../direct-upload-contents.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  05-13-2022 10:09   index.html
        0  05-13-2022 10:14   styles/
        0  05-13-2022 10:09   styles/style.css
        0  05-13-2022 10:14   scripts/
        0  05-13-2022 10:14   scripts/script.js
---------                     -------
        0                     5 files

Rather than this:

% zip --quiet -r direct-upload.zip webroot
% unzip -l direct-upload.zip
Archive:  direct-upload.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  05-13-2022 10:14   webroot/
        0  05-13-2022 10:09   webroot/index.html
        0  05-13-2022 10:14   webroot/styles/
        0  05-13-2022 10:09   webroot/styles/style.css
        0  05-13-2022 10:14   webroot/scripts/
        0  05-13-2022 10:14   webroot/scripts/script.js
---------                     -------
        0                     6 files

I compress the base dir (including subdirectories) of my project, not the (root)dit itself.

With Cloudflare Pages Direct Uploads I have no control how my uploaded ZIP is ‘unzipped’. It does that automatically

FYI

This is the contents of my zip file

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2022-05-12 11:16:48 ....A         5925         5925  android-chrome-192x192.png
2022-05-12 11:16:48 ....A        23352        23352  android-chrome-512x512.png
2022-05-12 11:16:48 ....A         4288         4288  apple-touch-icon.png
2022-05-06 15:19:23 ....A          103           75  appsettings.Development.json
2022-05-11 19:36:22 ....A           81           81  appsettings.Development.json.br
2022-05-11 19:36:22 ....A           80           80  appsettings.Development.json.gz
2022-05-09 14:12:28 ....A          127           91  appsettings.json
2022-05-11 19:36:22 ....A          103          103  appsettings.json.br
2022-05-11 19:36:22 ....A           99           99  appsettings.json.gz
2022-05-12 11:16:48 ....A          250          153  browserconfig.xml
2022-05-11 19:35:54 ....A         4184         1146  CrowTool.StaticBlazorWasmClient.styles.css
2022-05-10 15:07:47 ....A         2629         1455  css\app.css
2022-05-10 14:53:50 ....A       144676        21813  css\bootstrap\bootstrap.min.css
2022-05-09 22:23:43 ....A         1114          519  css\colorinfo.css
2022-05-09 14:19:47 ....A         9395         2005  css\open-iconic\font\css\open-iconic-bootstrap.min.css
2022-05-09 14:19:47 ....A        28196        14889  css\open-iconic\font\fonts\open-iconic.eot
2022-05-09 14:19:47 ....A        20996        12674  css\open-iconic\font\fonts\open-iconic.otf
2022-05-09 14:19:47 ....A        55332        12730  css\open-iconic\font\fonts\open-iconic.svg
2022-05-09 14:19:47 ....A        28028        14832  css\open-iconic\font\fonts\open-iconic.ttf
2022-05-09 14:19:47 ....A        14984        14959  css\open-iconic\font\fonts\open-iconic.woff
2022-05-09 14:19:47 ....A         3615         1460  css\open-iconic\README.md
2022-05-12 11:16:48 ....A          686          686  favicon-16x16.png
2022-05-12 11:16:49 ....A         1353         1353  favicon-32x32.png
2022-05-12 11:16:49 ....A         7406         3669  favicon.ico
2022-05-12 11:17:37 ....A         3123         1210  index.html
2021-08-10 18:14:32 ....A       155773        65203  js\decode.min.js
2022-05-12 11:16:50 ....A         3666         3629  mstile-150x150.png
2022-05-12 15:28:47 ....A          203          102  robots.txt
2022-05-12 11:16:50 ....A         4077         1838  safari-pinned-tab.svg
2022-05-01 12:14:21 ....A          410          136  sample-data\weather.json
2022-05-12 11:16:50 ....A          434          178  site.webmanifest
2022-05-13 14:08:47 ....A         5562         2664  _framework\blazor.boot.json
2022-05-13 14:08:47 ....A         2482         2482  _framework\blazor.boot.json.br
2022-05-13 14:08:47 ....A         2694         2694  _framework\blazor.boot.json.gz
2022-05-01 23:25:26 ....A        61192        18896  _framework\blazor.webassembly.js
2022-05-11 19:36:23 ....A        17103        17103  _framework\blazor.webassembly.js.br
2022-05-11 19:35:53 ....A        19515        19515  _framework\blazor.webassembly.js.gz
2022-03-28 14:18:40 ....A        23552         9928  _framework\Blazored.LocalStorage.dll
2022-05-11 19:36:23 ....A         8915         8915  _framework\Blazored.LocalStorage.dll.br
2022-05-11 19:36:22 ....A        10198        10198  _framework\Blazored.LocalStorage.dll.gz
2022-05-11 19:35:52 ....A         9728         3704  _framework\CrowTool.Shared.dll
2022-05-11 19:36:23 ....A         3179         3179  _framework\CrowTool.Shared.dll.br
2022-05-11 19:36:22 ....A         3833         3833  _framework\CrowTool.Shared.dll.gz
2022-05-11 19:35:54 ....A         7061         7061  _framework\CrowTool.Shared.pdb.gz
2022-05-12 18:45:49 ....A        43520        17862  _framework\CrowTool.StaticBlazorWasmClient.dll
2022-05-12 18:46:16 ....A        15909        15909  _framework\CrowTool.StaticBlazorWasmClient.dll.br
2022-05-12 18:46:15 ....A        18384        18384  _framework\CrowTool.StaticBlazorWasmClient.dll.gz
2022-05-12 18:45:49 ....A        28312        28312  _framework\CrowTool.StaticBlazorWasmClient.pdb.gz
2022-05-12 18:46:15 ....A       252976        71390  _framework\dotnet.7.0.0-preview.4.22229.4.3hawas5nuf.js
2022-05-12 18:46:16 ....A        59242        59242  _framework\dotnet.7.0.0-preview.4.22229.4.3hawas5nuf.js.br
2022-05-12 18:46:15 ....A        74051        74051  _framework\dotnet.7.0.0-preview.4.22229.4.3hawas5nuf.js.gz
2022-05-12 18:46:15 ....A      1037148       415953  _framework\dotnet.wasm
2022-05-12 18:46:18 ....A       367226       367226  _framework\dotnet.wasm.br
2022-05-12 18:46:15 ....A       436348       436348  _framework\dotnet.wasm.gz
2022-02-07 19:11:38 ....A       604672       205734  _framework\LinqToTwitter.dll
2022-05-11 19:36:25 ....A       161352       161310  _framework\LinqToTwitter.dll.br
2022-05-11 19:36:22 ....A       213614       210405  _framework\LinqToTwitter.dll.gz
2022-05-12 18:45:55 ....A       128512        53805  _framework\Microsoft.AspNetCore.Components.dll
2022-05-12 18:46:16 ....A        48100        48100  _framework\Microsoft.AspNetCore.Components.dll.br
2022-05-12 18:46:15 ....A        55682        55682  _framework\Microsoft.AspNetCore.Components.dll.gz
2022-05-12 18:45:55 ....A        40960        16434  _framework\Microsoft.AspNetCore.Components.Web.dll
2022-05-12 18:46:16 ....A        14096        14096  _framework\Microsoft.AspNetCore.Components.Web.dll.br
2022-05-12 18:46:15 ....A        16994        16961  _framework\Microsoft.AspNetCore.Components.Web.dll.gz
2022-05-12 18:45:55 ....A        43008        19163  _framework\Microsoft.AspNetCore.Components.WebAssembly.dll
2022-05-12 18:46:16 ....A        17521        17521  _framework\Microsoft.AspNetCore.Components.WebAssembly.dll.br
2022-05-12 18:46:15 ....A        19771        19771  _framework\Microsoft.AspNetCore.Components.WebAssembly.dll.gz
2022-05-12 18:45:55 ....A         6144         2337  _framework\Microsoft.Extensions.Configuration.Abstractions.dll
2022-05-12 18:46:16 ....A         2066         2066  _framework\Microsoft.Extensions.Configuration.Abstractions.dll.br
2022-05-12 18:46:15 ....A         2404         2404  _framework\Microsoft.Extensions.Configuration.Abstractions.dll.gz
2022-05-12 18:45:55 ....A         7680         3193  _framework\Microsoft.Extensions.Configuration.dll
2022-05-12 18:46:16 ....A         2870         2870  _framework\Microsoft.Extensions.Configuration.dll.br
2022-05-12 18:46:15 ....A         3286         3286  _framework\Microsoft.Extensions.Configuration.dll.gz
2022-05-12 18:45:55 ....A         8192         3541  _framework\Microsoft.Extensions.Configuration.Json.dll
2022-05-12 18:46:16 ....A         3238         3238  _framework\Microsoft.Extensions.Configuration.Json.dll.br
2022-05-12 18:46:15 ....A         3664         3664  _framework\Microsoft.Extensions.Configuration.Json.dll.gz
2022-05-12 18:45:55 ....A        13824         5398  _framework\Microsoft.Extensions.DependencyInjection.Abstractions.dll
2022-05-12 18:46:16 ....A         4872         4872  _framework\Microsoft.Extensions.DependencyInjection.Abstractions.dll.br
2022-05-12 18:46:15 ....A         5574         5574  _framework\Microsoft.Extensions.DependencyInjection.Abstractions.dll.gz
2022-05-12 18:45:55 ....A        35840        16716  _framework\Microsoft.Extensions.DependencyInjection.dll
2022-05-12 18:46:16 ....A        15209        15209  _framework\Microsoft.Extensions.DependencyInjection.dll.br
2022-05-12 18:46:15 ....A        17217        17217  _framework\Microsoft.Extensions.DependencyInjection.dll.gz
2022-05-12 18:45:55 ....A        26112        11303  _framework\Microsoft.Extensions.Logging.Abstractions.dll
2022-05-12 18:46:16 ....A         9940         9940  _framework\Microsoft.Extensions.Logging.Abstractions.dll.br
2022-05-12 18:46:15 ....A        11666        11666  _framework\Microsoft.Extensions.Logging.Abstractions.dll.gz
2022-05-12 18:45:55 ....A        16384         7754  _framework\Microsoft.Extensions.Logging.dll
2022-05-12 18:46:16 ....A         7039         7039  _framework\Microsoft.Extensions.Logging.dll.br
2022-05-12 18:46:15 ....A         7984         7984  _framework\Microsoft.Extensions.Logging.dll.gz
2022-05-12 18:45:55 ....A        16384         7435  _framework\Microsoft.Extensions.Options.dll
2022-05-12 18:46:16 ....A         6785         6785  _framework\Microsoft.Extensions.Options.dll.br
2022-05-12 18:46:15 ....A         7698         7698  _framework\Microsoft.Extensions.Options.dll.gz
2022-05-12 18:45:55 ....A         8192         3365  _framework\Microsoft.Extensions.Primitives.dll
2022-05-12 18:46:16 ....A         3038         3038  _framework\Microsoft.Extensions.Primitives.dll.br
2022-05-12 18:46:15 ....A         3476         3476  _framework\Microsoft.Extensions.Primitives.dll.gz
2022-05-12 18:45:55 ....A        37888        16502  _framework\Microsoft.JSInterop.dll
2022-05-12 18:46:16 ....A        14983        14983  _framework\Microsoft.JSInterop.dll.br
2022-05-12 18:46:15 ....A        16987        16987  _framework\Microsoft.JSInterop.dll.gz
2022-05-12 18:45:55 ....A         8704         3743  _framework\Microsoft.JSInterop.WebAssembly.dll
2022-05-12 18:46:16 ....A         3438         3438  _framework\Microsoft.JSInterop.WebAssembly.dll.br
2022-05-12 18:46:15 ....A         3860         3860  _framework\Microsoft.JSInterop.WebAssembly.dll.gz
2022-05-12 18:45:55 ....A        17408         7590  _framework\System.Collections.Concurrent.dll
2022-05-12 18:46:16 ....A         7062         7062  _framework\System.Collections.Concurrent.dll.br
2022-05-12 18:46:15 ....A         7785         7785  _framework\System.Collections.Concurrent.dll.gz
2022-05-12 18:45:55 ....A         7168         3018  _framework\System.Collections.dll
2022-05-12 18:46:16 ....A         2790         2790  _framework\System.Collections.dll.br
2022-05-12 18:46:15 ....A         3113         3113  _framework\System.Collections.dll.gz
2022-05-12 18:45:55 ....A         4096         1490  _framework\System.ComponentModel.dll
2022-05-12 18:46:16 ....A         1381         1381  _framework\System.ComponentModel.dll.br
2022-05-12 18:46:15 ....A         1539         1539  _framework\System.ComponentModel.dll.gz
2022-05-12 18:45:55 ....A         9728         4075  _framework\System.ComponentModel.Primitives.dll
2022-05-12 18:46:16 ....A         3701         3701  _framework\System.ComponentModel.Primitives.dll.br
2022-05-12 18:46:15 ....A         4203         4203  _framework\System.ComponentModel.Primitives.dll.gz
2022-05-12 18:45:55 ....A         8704         3894  _framework\System.ComponentModel.TypeConverter.dll
2022-05-12 18:46:16 ....A         3584         3584  _framework\System.ComponentModel.TypeConverter.dll.br
2022-05-12 18:46:15 ....A         4009         4009  _framework\System.ComponentModel.TypeConverter.dll.gz
2022-05-12 18:45:55 ....A        13312         6410  _framework\System.Console.dll
2022-05-12 18:46:16 ....A         5705         5705  _framework\System.Console.dll.br
2022-05-12 18:46:15 ....A         6609         6609  _framework\System.Console.dll.gz
2022-05-12 18:45:55 ....A         4096         1393  _framework\System.dll
2022-05-12 18:46:16 ....A         1258         1258  _framework\System.dll.br
2022-05-12 18:46:15 ....A         1448         1448  _framework\System.dll.gz
2022-05-12 18:45:55 ....A        30720        13260  _framework\System.IO.Compression.dll
2022-05-12 18:46:16 ....A        11759        11759  _framework\System.IO.Compression.dll.br
2022-05-12 18:46:15 ....A        13671        13671  _framework\System.IO.Compression.dll.gz
2022-05-12 18:45:55 ....A        33280        14226  _framework\System.Linq.dll
2022-05-12 18:46:16 ....A        12608        12608  _framework\System.Linq.dll.br
2022-05-12 18:46:15 ....A        14669        14669  _framework\System.Linq.dll.gz
2022-05-12 18:45:55 ....A       349184       129144  _framework\System.Linq.Expressions.dll
2022-05-12 18:46:17 ....A       110657       110657  _framework\System.Linq.Expressions.dll.br
2022-05-12 18:46:15 ....A       133851       133715  _framework\System.Linq.Expressions.dll.gz
2022-05-12 18:45:55 ....A        18432         8413  _framework\System.Linq.Queryable.dll
2022-05-12 18:46:16 ....A         7700         7700  _framework\System.Linq.Queryable.dll.br
2022-05-12 18:46:15 ....A         8687         8687  _framework\System.Linq.Queryable.dll.gz
2022-05-12 18:45:55 ....A         5632         2475  _framework\System.Memory.Data.dll
2022-05-12 18:46:16 ....A         2277         2277  _framework\System.Memory.Data.dll.br
2022-05-12 18:46:15 ....A         2553         2553  _framework\System.Memory.Data.dll.gz
2022-05-12 18:45:55 ....A        16896         7930  _framework\System.Memory.dll
2022-05-12 18:46:16 ....A         7209         7209  _framework\System.Memory.dll.br
2022-05-12 18:46:15 ....A         8156         8156  _framework\System.Memory.dll.gz
2022-05-12 18:45:55 ....A       139264        59906  _framework\System.Net.Http.dll
2022-05-12 18:46:16 ....A        53526        53526  _framework\System.Net.Http.dll.br
2022-05-12 18:46:15 ....A        61797        61797  _framework\System.Net.Http.dll.gz
2022-05-12 18:45:55 ....A        14336         6366  _framework\System.Net.Http.Json.dll
2022-05-12 18:46:16 ....A         5764         5764  _framework\System.Net.Http.Json.dll.br
2022-05-12 18:46:15 ....A         6551         6551  _framework\System.Net.Http.Json.dll.gz
2022-05-12 18:45:55 ....A        24064        12029  _framework\System.Net.Primitives.dll
2022-05-12 18:46:16 ....A        10389        10389  _framework\System.Net.Primitives.dll.br
2022-05-12 18:46:15 ....A        12457        12457  _framework\System.Net.Primitives.dll.gz
2022-05-12 18:45:55 ....A         5120         2058  _framework\System.Net.Sockets.dll
2022-05-12 18:46:16 ....A         1857         1857  _framework\System.Net.Sockets.dll.br
2022-05-12 18:46:15 ....A         2128         2128  _framework\System.Net.Sockets.dll.gz
2022-05-12 18:45:55 ....A         5120         1988  _framework\System.ObjectModel.dll
2022-05-12 18:46:16 ....A         1792         1792  _framework\System.ObjectModel.dll.br
2022-05-12 18:46:15 ....A         2049         2049  _framework\System.ObjectModel.dll.gz
2022-05-12 18:45:55 ....A      1136640       443826  _framework\System.Private.CoreLib.dll
2022-05-12 18:46:19 ....A       385355       385355  _framework\System.Private.CoreLib.dll.br
2022-05-12 18:46:15 ....A       462584       461110  _framework\System.Private.CoreLib.dll.gz
2022-05-12 18:45:55 ....A        19456         9312  _framework\System.Private.Runtime.InteropServices.JavaScript.dll
2022-05-12 18:46:19 ....A         8385         8385  _framework\System.Private.Runtime.InteropServices.JavaScript.dll.br
2022-05-12 18:46:15 ....A         9627         9627  _framework\System.Private.Runtime.InteropServices.JavaScript.dll.gz
2022-05-12 18:45:55 ....A        62464        28042  _framework\System.Private.Uri.dll
2022-05-12 18:46:19 ....A        25778        25778  _framework\System.Private.Uri.dll.br
2022-05-12 18:46:15 ....A        28948        28948  _framework\System.Private.Uri.dll.gz
2022-05-12 18:45:55 ....A        71168         8978  _framework\System.Private.Xml.dll
2022-05-12 18:46:16 ....A         7319         7319  _framework\System.Private.Xml.dll.br
2022-05-12 18:46:15 ....A        10029         9987  _framework\System.Private.Xml.dll.gz
2022-05-12 18:45:55 ....A         8192         2861  _framework\System.Runtime.dll
2022-05-12 18:46:16 ....A         2520         2520  _framework\System.Runtime.dll.br
2022-05-12 18:46:15 ....A         2943         2943  _framework\System.Runtime.dll.gz
2022-05-12 18:45:55 ....A         4096         1526  _framework\System.Security.Cryptography.Algorithms.dll
2022-05-12 18:46:16 ....A         1391         1391  _framework\System.Security.Cryptography.Algorithms.dll.br
2022-05-12 18:46:15 ....A         1579         1579  _framework\System.Security.Cryptography.Algorithms.dll.gz
2022-05-12 18:45:55 ....A        19968         9066  _framework\System.Security.Cryptography.dll
2022-05-12 18:46:16 ....A         8022         8022  _framework\System.Security.Cryptography.dll.br
2022-05-12 18:46:15 ....A         9282         9282  _framework\System.Security.Cryptography.dll.gz
2022-05-12 18:45:55 ....A         4096         1519  _framework\System.Security.Cryptography.Primitives.dll
2022-05-12 18:46:16 ....A         1396         1396  _framework\System.Security.Cryptography.Primitives.dll.br
2022-05-12 18:46:15 ....A         1571         1571  _framework\System.Security.Cryptography.Primitives.dll.gz
2022-05-12 18:45:55 ....A        27648         9498  _framework\System.Text.Encodings.Web.dll
2022-05-12 18:46:16 ....A         8631         8631  _framework\System.Text.Encodings.Web.dll.br
2022-05-12 18:46:15 ....A         9807         9807  _framework\System.Text.Encodings.Web.dll.gz
2022-05-12 18:45:55 ....A       310784       117854  _framework\System.Text.Json.dll
2022-05-12 18:46:17 ....A       102844       102844  _framework\System.Text.Json.dll.br
2022-05-12 18:46:15 ....A       121998       121926  _framework\System.Text.Json.dll.gz
2022-05-12 18:45:55 ....A        12800         6123  _framework\System.Text.RegularExpressions.dll
2022-05-12 18:46:16 ....A         5530         5530  _framework\System.Text.RegularExpressions.dll.br
2022-05-12 18:46:15 ....A         6304         6304  _framework\System.Text.RegularExpressions.dll.gz
2022-05-12 18:45:55 ....A        11776         4130  _framework\System.Threading.dll
2022-05-12 18:46:16 ....A         3606         3606  _framework\System.Threading.dll.br
2022-05-12 18:46:15 ....A         4254         4254  _framework\System.Threading.dll.gz
2022-05-12 18:45:55 ....A         5632         2312  _framework\System.Web.HttpUtility.dll
2022-05-12 18:46:16 ....A         2141         2141  _framework\System.Web.HttpUtility.dll.br
2022-05-12 18:46:15 ....A         2366         2366  _framework\System.Web.HttpUtility.dll.gz
2022-05-12 18:45:55 ....A         4096         1513  _framework\System.Xml.ReaderWriter.dll
2022-05-12 18:46:16 ....A         1409         1409  _framework\System.Xml.ReaderWriter.dll.br
2022-05-12 18:46:15 ....A         1560         1560  _framework\System.Xml.ReaderWriter.dll.gz
2022-05-12 18:45:55 ....A         4096         1499  _framework\System.Xml.XmlSerializer.dll
2022-05-12 18:46:16 ....A         1398         1398  _framework\System.Xml.XmlSerializer.dll.br
2022-05-12 18:46:15 ....A         1549         1549  _framework\System.Xml.XmlSerializer.dll.gz
------------------- ----- ------------ ------------  ------------------------
2022-05-13 14:08:47            8935630      5621565  198 files

And here’s the output once it’s uploaded to Cloudflare Pages Direct Upload. No subdirectories visible.

I think this is a bug.

My dummy placeholder site does not have the same behaviour, and some mta-sts sites I deployed behave as expected (where the only file that matters is in a subdirectory). The directory appears at the end of my list, so not in alphabetical order.

I’ll get a bigger dummy site and see if the behaviour changes.

Dummy site exhibits the exact same behaviour, (but it stripped the mp4 video!)

You can see the complete upload in my screenshots: 1/2 & 2/2, and there are no subdirectories visible.

That’s why I put a small red arrow near the scrollbar.

I’ve tried it with 2 different ZIP archivers. Windows 10 Internal & 7z.

This is what I expect to see, in any sort order.

After spending more time creating ZIP files with different CLI parameters on Windows 10 I found a solution.

When I looked inside the ZIP archives I created everything looked okay, with all the subdirectories in it. When I locally unzipped them everything was okay too. All of the contents and subdirectories were unzipped and created.

But when I uploaded the ZIP file to Cloudflare pages the subdirectories weren’t created. I still don’t know why this is. I think ZIP files behave differently on Windows and Linux.

To create a ZIP file with subdirectories that works on Cloudflare Pages/Linux too use the following (simple) 7z CLI command

7z a -r -y myarchive.zip *

OR

7z a -r -y myarchive.zip

The CLI command I previously used and didn’t work was 7z a -r -y myarchive.zip *.* (so *.* instead of * or nothing. Creating a ZIP with subdirectories with the internal Windows 10 GUI ZIP archiver (select files and subdirectories from Windows Explorer) doesn’t work as well. So you’ll need a command line tool like 7z.exe