johannesboyne / gofakes3

A simple fake AWS S3 object storage (used for local test-runs against AWS S3 APIs)
MIT License
358 stars 81 forks source link

Bug: Can not support create Folder. #93

Open akang943578 opened 2 months ago

akang943578 commented 2 months ago

I am using WinSCP to connect S3, which was created by Alist. When I try to create folder under a bucket, actually I got a file. image

The logic for creating folder in WinSCP is as follows: a request with a path ending in a slash (/) indicates a folder creation, e.g., PUT /test-localhost/testFolder/. Conversely, for file creation, the request path does not end with a slash, e.g., PUT /test-localhost/testFolder/1.txt.

However, there is an issue with the implementation in gofakes3. It directly trims the path, which disregards the trailing slash, treating all requests as file creation.

You can see this in the source code: https://github.com/johannesboyne/gofakes3/blob/master/routing.go#L23

This trimming operation affects all S3 requests. While I can modify the PutObject function, I'm unsure if other S3 requests are also affected. It's quite confusing.

Related Issue: https://github.com/alist-org/alist/issues/6588

As you are the original owner of gofakes3 repository, can you give advise how to fix it? Is only PutObject affected, or all the S3 operations affected? Can you have time to investigate it and fix it, since you know the whole structure and can evaluate all the affections. Thanks.