mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
fix upload file example in changelog (#504)
This commit is contained in:
parent
22a2a69d65
commit
4ccea8d6a1
1 changed files with 4 additions and 4 deletions
|
@ -9,16 +9,16 @@
|
||||||
|
|
||||||
Here's a fully working sample for reading a image file upload `image1` and saving it under `public/uploads`.
|
Here's a fully working sample for reading a image file upload `image1` and saving it under `public/uploads`.
|
||||||
|
|
||||||
```crystal
|
```crystal
|
||||||
post "/upload" do |env|
|
post "/upload" do |env|
|
||||||
file = env.params.files["image1"].tmpfile
|
file = env.params.files["image1"].tempfile
|
||||||
file_path = ::File.join [Kemal.config.public_folder, "uploads/", file.filename]
|
file_path = ::File.join [Kemal.config.public_folder, "uploads/", File.basename(file.path)]
|
||||||
File.open(file_path, "w") do |f|
|
File.open(file_path, "w") do |f|
|
||||||
IO.copy(file, f)
|
IO.copy(file, f)
|
||||||
end
|
end
|
||||||
"Upload ok"
|
"Upload ok"
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
To test
|
To test
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue