Skip to content

Commit

Permalink
Add /compress/v2 API endpoint to help clients.
Browse files Browse the repository at this point in the history
  • Loading branch information
retrixe committed Aug 25, 2023
1 parent c04ce2c commit 30f9c99
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions API.md
Expand Up @@ -455,9 +455,9 @@ Move or copy a file or folder in the working directory of the app.

### POST /server/{id}/compress?path=path&compress=algorithm&archiveType=archiveType

Compress files/folders in the working directory of the app into a ZIP or TAR archive.
Compress files/folders in the working directory of the app into a ZIP or TAR archive. Support for `tar(.gz/xz/zst)` archives was added in v1.2+.

Support for `tar(.gz/xz/zst)` archives was added in v1.2+.
⚠️ *Info:* The `POST /server/{id}/compress/v2` API is available as well, which is identical to this, but guaranteed to support `tar` archives, and can be used by API clients to ensure archives aren't accidentally created as ZIP files on older Octyne versions.

**Request Query Parameters:**

Expand Down
7 changes: 5 additions & 2 deletions endpoints_files.go
Expand Up @@ -354,7 +354,8 @@ func (connector *Connector) registerFileRoutes() {
})

// POST /server/{id}/compress?path=path&compress=true/false/zstd/xz/gzip&archiveType=zip/tar
connector.Router.HandleFunc("/server/{id}/compress", func(w http.ResponseWriter, r *http.Request) {
// POST /server/{id}/compress/v2?path=path&compress=true/false/zstd/xz/gzip&archiveType=zip/tar
compressionEndpoint := func(w http.ResponseWriter, r *http.Request) {
// Check with authenticator.
user := connector.Validate(w, r)
if user == "" {
Expand Down Expand Up @@ -480,7 +481,9 @@ func (connector *Connector) registerFileRoutes() {
"archive", clean(r.URL.Query().Get("path")), "archiveType", archiveType,
"compression", compression, "files", files)
writeJsonStringRes(w, "{\"success\":true}")
})
}
connector.Router.HandleFunc("/server/{id}/compress", compressionEndpoint)
connector.Router.HandleFunc("/server/{id}/compress/v2", compressionEndpoint)

// POST /server/{id}/decompress?path=path
connector.Router.HandleFunc("/server/{id}/decompress", func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 30f9c99

Please sign in to comment.