NAME

WWW::Suffit::Server::API::NoAPI - The Suffit NoAPI controller

SYNOPSIS

use WWW::Suffit::Server::API::NoAPI;

DESCRIPTION

The Suffit NoAPI controller

METHODS

List of internal methods

file_download

See "GET /api/file/FILEPATH"

file_list

See "GET /api/file"

file_remove

See "DELETE /api/file/FILEPATH"

file_upload

See "PUT /api/file/FILEPATH"

API METHODS

List of API methods

DELETE /api/file/FILEPATH

Remove file from server

# curl -v -H "Authorization: Bearer eyJh...GBew" \
  -X DELETE \
  https://localhost:8695/api/file/foo/bar/test123.txt

> DELETE /api/file/foo/bar/test123.txt HTTP/1.1
> Host: localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer eyJh...GBew
>
< HTTP/1.1 200 OK
< Content-Length: 30
< Content-Type: application/json;charset=UTF-8
< Date: Wed, 14 Aug 2024 11:27:09 GMT
< Server: OWL/1.11
<
{
  "code": "E0000",
  "status": true
}

GET /api/file

Get a list of files on the server (manifest)

# curl -v -H "Authorization: Bearer eyJh...s5aM" \
  https://localhost:8695/api/file

> GET /api/file HTTP/1.1
> Host: localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer eyJh...s5aM
>
< HTTP/1.1 200 OK
< Content-Length: 1081
< Content-Type: application/json;charset=UTF-8
< Date: Wed, 14 Aug 2024 11:17:42 GMT
< Server: OWL/1.11
< Vary: Accept-Encoding
<
{
  "documentroot": "/home/foo/tmp/owl/public",
  "manifest": [
    {
      "absf": "/",
      "directory": "/",
      "filename": "",
      "id": 9962787,
      "mdate": 1701365824,
      "path": "/",
      "perms": 509,
      "pid": 0,
      "size": 4096,
      "type": "folder"
    },
    {
      "absf": "/foo",
      "directory": "/",
      "filename": "foo",
      "id": 9962956,
      "mdate": 1690565423,
      "path": "foo",
      "perms": 509,
      "pid": 9962787,
      "size": 4096,
      "type": "folder"
    },
    {
      "absf": "/foo/bar",
      "directory": "/foo",
      "filename": "bar",
      "id": 9962957,
      "mdate": 1723634001,
      "path": "foo/bar",
      "perms": 509,
      "pid": 9962956,
      "size": 4096,
      "type": "folder"
    },
    {
      "absf": "/foo/bar/test123.txt",
      "directory": "/foo/bar",
      "filename": "test123.txt",
      "id": 9963558,
      "mdate": 1723634001,
      "path": "foo/bar/test123.txt",
      "perms": 436,
      "pid": 9962957,
      "size": 490,
      "type": "file"
    },
  ],
  "status": true
}

GET /api/file/FILEPATH

Download file from server

# curl -v -H "Authorization: Bearer eyJh...GBew" \
  https://localhost:8695/api/file/foo/bar/test123.txt

> GET /api/file/foo/bar/test123.txt HTTP/1.1
> Host: localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer eyJh...GBew
>
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Content-Length: 490
< Content-Type: text/plain;charset=UTF-8
< Date: Wed, 14 Aug 2024 11:24:32 GMT
< ETag: "5946bf06113340241d59cbf2c940eede"
< Last-Modified: Wed, 14 Aug 2024 11:13:21 GMT
< Server: OWL/1.11
<
...content of the file...

PUT /api/file/FILEPATH

Upload file to server

# curl -v -H "Authorization: Bearer eyJh...GBew" \
  -X PUT -F size=490 \
  -F md5=acaa9dd36fe3b6758e91129170910378 -F fileraw=@test123.txt \
  https://localhost:8695/api/file/foo/bar/test123.txt

> PUT /api/file/foo/bar/test123.txt HTTP/1.1
> Host: localhost:8695
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: Bearer eyJh...GBew
> Content-Length: 902
> Content-Type: multipart/form-data; boundary=...
>
< HTTP/1.1 200 OK
< Content-Length: 182
< Content-Type: application/json;charset=UTF-8
< Date: Wed, 14 Aug 2024 11:13:21 GMT
< Server: OWL/1.11
<
{
  "code": "E0000",
  "file": "/home/foo/tmp/owl/public/foo/bar/test123.txt",
  "md5": "acaa9dd36fe3b6758e91129170910378",
  "size": "490",
  "status": true,
  "uploaded": "2024-08-14T11:13:21Z"
}

ERROR CODES

List of NoAPI Suffit API error codes

 API   | HTTP  | DESCRIPTION
-------+-------+-------------------------------------------------
 E1110   [400]   No file path specified
 E1111   [400]   Incorrect file path
 E1112   [404]   File not found
 E1113   [500]   Can't upload file
 E1114   [500]   Can't upload file: file is lost
 E1115   [400]   File size mismatch
 E1116   [400]   File md5 checksum mismatch
 E1117   [---]   Reserved
 E1118   [---]   Reserved
 E1119   [---]   Reserved

* -- this code will be defined later on the interface side

See also list of common Suffit API error codes in "ERROR CODES" in WWW::Suffit::API

HISTORY

See Changes file

TO DO

See TODO file

SEE ALSO

Mojolicious, WWW::Suffit, WWW::Suffit::Server, WWW::Suffit::API

AUTHOR

Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>

COPYRIGHT

Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved

LICENSE

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See LICENSE file and https://dev.perl.org/licenses/