flaviostutz / flaviostutz/simple-file-server
Issue with the PUT request.
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17
- Forks
- 6
- PR merge metrics
- No merged PRs in 30d
Description
I was testing this package, and I noticed that on a put request it doesn't overwrite the file the way I was expecting it to.
Test case was I posted a json file. Then I ran an update on that file will less content. It only replaced the amount of characters in the new file, but left the rest of the old file. Then I tested it with images, and though it displays the proper image, it still keeps the old bytes and size.
Example json post 1 => {"test1":"test1", "test2":"test2222222222222222222222"}
result => {"test1":"test1", "test2":"test2222222222222222222222"}
Example json post 2 => {"test1":"test1", "test2":"test2"}
result => {"test1":"test1", "test2":"test2"}2222222222222222222"}
Tested image size 1.3mb first. then uploaded a smaller image with the same name at 12kb. After uploading the file, the file size stayed the same, but showed the newer image.
I added this to the file_server.go and it fixed the issue. I was wondering if you could patch this and repush the image / repo?
Thanks in advance.
```
f.Truncate(0)
f.Seek(0, 0)
fsize, err := io.Copy(f, r.Body)
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in file_server.go at the PUT file-writing path and reproduce the reported sequence with a longer JSON or image followed by a shorter replacement. Verify that the stored content and file size match the replacement completely, including the provided f.Truncate and f.Seek behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100