cmj2002 / r2-dir-list

Directory Listing for Cloudflare R2
MIT License
25 stars 8 forks source link

Feature request: Compatibility with 0-byte placeholder objects generated by S3 tools #3

Closed sergiozygmunt closed 1 month ago

sergiozygmunt commented 1 month ago

I deployed the Worker and the root "directory" renders but when clicking into a "subdirectory" a 0 byte file called "download" is downloaded instead. My instance is at the domain r2-dir-list-issue-3.sergiozygmunt.dev forwards to (it is not at that domain).

Screenshot 2024-08-05 at 23 10 19
cmj2002 commented 1 month ago

Can you screenshot the list of objects in the bucket in cloudflare dashboard?

sergiozygmunt commented 1 month ago

Sure thing Image: The image shows a web interface for managing files in a cloud storage bucket. The header includes details such as the bucket name, public URL access status (not allowed), domains, bucket size, and operation counts. There are tabs for “Objects,” “Metrics,” and “Settings,” along with a search box for filtering objects. The file list displays various files and directories under a general prefix, with types, sizes, and modification statuses noted. Several files are marked as “Ongoing Multipart Upload,” indicating they are being uploaded in parts. The directories are labeled with generic names like “company1,” “company2,” and “company3.” The interface includes “Refresh” and “Upload” buttons, and a note that files can be dragged and dropped to start uploading. This setup is used for managing and uploading files to a public repository, although public access is currently restricted.

cmj2002 commented 1 month ago

Please unselect the "view prefixes as directories"

I guess the directory is empty, it's only a placeholder file created by your s3 tool.

sergiozygmunt commented 1 month ago

Here's what it looks like unchecked The image shows a web interface for managing files in a cloud storage bucket. The header includes the bucket name, public URL access status (not allowed), domains, bucket size, and operation counts. There are tabs for “Objects,” “Metrics,” and “Settings,” with a search box for filtering objects by prefix. The file list displays various files and directories under a general prefix, detailing their types, sizes, and modification dates. Several files are marked as “Ongoing Multipart Upload,” indicating they are in the process of being uploaded. Directories are labeled with generic names, such as “folder1,” “folder2,” and “folder3.” The interface includes buttons for “Refresh” and “Upload,” and a note that files can be dragged and dropped to start uploading. This setup is used for managing and uploading files to a public repository, with current public access restricted. This image differs from the previous image because it shows that for "folder1" there is a blank 0 byte file with the mimetype application/x-directory, suggesting that the S3 client used to upload the files is making a blank file.

cmj2002 commented 1 month ago

My previous guess was correct, you are using some S3 tool that automatically creates an object named apple/ (or name of other directory) . If the object exists in the bucket when requesting a URL, the program will directly return the object without generating a page. This is intentional to prevent disrupting normal reading of objects. You need to edit your tool's settings to prevent it from doing so, or switch to a different tool.

sergiozygmunt commented 1 month ago

I am using cyberduck - here's what it looks like in the software The image shows a file management interface within a cloud storage application. The interface lists files and directories under a general prefix. The header indicates the connection status and provides options for actions such as “Open Connection,” “Action,” “Refresh,” “Edit,” and “Search.”

Directories are labeled with generic names like “folder1,” “folder2,” “folder3,” and so on. Inside these directories, there are files with sizes and modification dates, such as “file1.zip,” “file2.zip,” and “file3.zip,” with details indicating their sizes and modification dates. The sizes of the files are in gigabytes, and the modification dates are listed in a month/day/year format with timestamps.

The interface is used for managing and navigating through various files and directories within a cloud storage environment.

Are you saying there's a blank object called "apple" that is causing the worker to not work? Do you have a s3 client that works better with the worker?

cmj2002 commented 1 month ago

I use S3 browser but it doesn't integrate with finder. If you can wait, I will add an option to ignore 0-byte files when I am back from vacation next Monday.

sergiozygmunt commented 1 month ago

Yes I can absolutely wait – I would greatly appreciate any enhancements for the 0-byte files.

cmj2002 commented 1 month ago

You can enable the new dangerousOverwriteZeroByteObject option.

sergiozygmunt commented 1 month ago

@cmj2002 works great - thanks!!!