Skip to content

Commit

Permalink
explain POST in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
LiviaMedeiros committed Aug 19, 2023
1 parent e4e662a commit 783e7d2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ import poteto from 'poteto';
});
}

// write partial file range
// write partial file range with POST
{
const { statusText } = await poteto('new_file.txt', {
method: 'PUT',
method: 'POST',
body: 'fileUNUSED',
headers: {
'Range': 'bytes=4-7',
Expand Down Expand Up @@ -183,6 +183,12 @@ Just to mirror `GET` and `READ`. They are different in the same way, but there s
Also `PUT` supports `Range` header which allows it to write in user-defined file positions.
## What is the difference between `POST` and `PUT`
`POST` opens file with `r+` flag while `PUT` uses `w+`. Which means:
- `POST` can write partial file range in existing file without rewriting, but `PUT` will truncate the end and fill beginning with NUL bytes.
- `PUT` will create new files or overwrite existing ones, but `POST` will return `404` if the file doesn't exist yet.
## Why is it called like that
No particular reason.
Expand Down

0 comments on commit 783e7d2

Please sign in to comment.