Skip to content

Commit

Permalink
Add ability to create folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija committed Nov 8, 2024
1 parent cb4facb commit a9af65a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ REST web API for the [libgphoto2](http://www.gphoto.org) library. You can use it
- `GET /cameras/:id/fs`
- `GET /cameras/:id/fs/*path`
- `DELETE /cameras/:id/fs/*path`
- `PUT /cameras/:id/fs/*path`

#### `/cameras/:id/blob`

Expand Down
15 changes: 15 additions & 0 deletions src/gphoto2/web/routes.cr
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ delete "/cameras/:id/fs/*path" do |env|
send_204 env
end

put "/cameras/:id/fs/*path" do |env|
id = env.params.url["id"]
path = env.params.url["path"]

GPhoto2::Web.camera_by_id(id) do |camera|
path = Path.posix("/", path)

folder = camera
.filesystem(path.dirname)
.mkdir(path.basename)

send_json env, folder
end
end

# /cameras/:id/blob

get "/cameras/:id/blob/*filepath" do |env|
Expand Down

0 comments on commit a9af65a

Please sign in to comment.