move path to params
This commit is contained in:
@@ -27,13 +27,13 @@ func NewStorageHandler() *StorageHandler {
|
|||||||
func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
||||||
handler := NewStorageHandler()
|
handler := NewStorageHandler()
|
||||||
|
|
||||||
r.Get("/list-content", handler.ListContent)
|
r.Get("/list-content/*", handler.ListContent)
|
||||||
r.Get("/download-file", handler.DownloadFile)
|
r.Get("/download-file/*", handler.DownloadFile)
|
||||||
|
|
||||||
r.Post("/upload-file", handler.UploadFile)
|
r.Post("/upload-file/*", handler.UploadFile)
|
||||||
r.Get("/create-folder", handler.CreateFolder)
|
r.Get("/create-folder/*", handler.CreateFolder)
|
||||||
r.Delete("/delete-file", handler.DeleteFile)
|
r.Delete("/delete-file/*", handler.DeleteFile)
|
||||||
r.Delete("/delete-folder", handler.DeleteFolder)
|
r.Delete("/delete-folder/*", handler.DeleteFolder)
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
@@ -41,7 +41,7 @@ func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
|||||||
// accepted path looks like e.g. "/folder1/" or "folder1"
|
// accepted path looks like e.g. "/folder1/" or "folder1"
|
||||||
func (h *StorageHandler) ListContent(c fiber.Ctx) error {
|
func (h *StorageHandler) ListContent(c fiber.Ctx) error {
|
||||||
// relative path defaults to root directory
|
// relative path defaults to root directory
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
@@ -58,7 +58,7 @@ func (h *StorageHandler) ListContent(c fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *StorageHandler) DownloadFile(c fiber.Ctx) error {
|
func (h *StorageHandler) DownloadFile(c fiber.Ctx) error {
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
@@ -72,11 +72,12 @@ func (h *StorageHandler) DownloadFile(c fiber.Ctx) error {
|
|||||||
|
|
||||||
c.Attachment(filename)
|
c.Attachment(filename)
|
||||||
c.Set("Content-Length", strconv.FormatInt(filesize, 10))
|
c.Set("Content-Length", strconv.FormatInt(filesize, 10))
|
||||||
|
c.Set("Content-Type", "application/octet-stream")
|
||||||
return c.SendStream(f, int(filesize))
|
return c.SendStream(f, int(filesize))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *StorageHandler) UploadFile(c fiber.Ctx) error {
|
func (h *StorageHandler) UploadFile(c fiber.Ctx) error {
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
@@ -98,7 +99,7 @@ func (h *StorageHandler) UploadFile(c fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *StorageHandler) CreateFolder(c fiber.Ctx) error {
|
func (h *StorageHandler) CreateFolder(c fiber.Ctx) error {
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
@@ -114,7 +115,7 @@ func (h *StorageHandler) CreateFolder(c fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *StorageHandler) DeleteFile(c fiber.Ctx) error {
|
func (h *StorageHandler) DeleteFile(c fiber.Ctx) error {
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
@@ -130,7 +131,7 @@ func (h *StorageHandler) DeleteFile(c fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *StorageHandler) DeleteFolder(c fiber.Ctx) error {
|
func (h *StorageHandler) DeleteFolder(c fiber.Ctx) error {
|
||||||
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Query("path"))
|
abs_path, err := h.storageService.AbsPath(h.config.Storage.RootFolder, c.Params("*"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Status(responseErrors.GetErrorStatus(err)).
|
return c.Status(responseErrors.GetErrorStatus(err)).
|
||||||
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
JSON(response.Make(nullable.GetNil(""), 0, responseErrors.GetErrorCode(c, err)))
|
||||||
|
|||||||
7
bruno/b2b_daniel/auth/folder.yml
Normal file
7
bruno/b2b_daniel/auth/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: auth
|
||||||
|
type: folder
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: update-choice
|
name: update-choice
|
||||||
type: http
|
type: http
|
||||||
seq: 6
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: add-new-cart
|
name: add-new-cart
|
||||||
type: http
|
type: http
|
||||||
seq: 14
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: add-product-to-cart (1)
|
name: add-product-to-cart (1)
|
||||||
type: http
|
type: http
|
||||||
seq: 19
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: add-product-to-cart
|
name: add-product-to-cart
|
||||||
type: http
|
type: http
|
||||||
seq: 18
|
seq: 14
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: change-cart-name
|
name: change-cart-name
|
||||||
type: http
|
type: http
|
||||||
seq: 15
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
7
bruno/b2b_daniel/carts/folder.yml
Normal file
7
bruno/b2b_daniel/carts/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: carts
|
||||||
|
type: folder
|
||||||
|
seq: 7
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: retrieve-cart
|
name: retrieve-cart
|
||||||
type: http
|
type: http
|
||||||
seq: 17
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: retrieve-carts-info
|
name: retrieve-carts-info
|
||||||
type: http
|
type: http
|
||||||
seq: 16
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
7
bruno/b2b_daniel/langs-and-countries/folder.yml
Normal file
7
bruno/b2b_daniel/langs-and-countries/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: langs-and-countries
|
||||||
|
type: folder
|
||||||
|
seq: 4
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: get_countries
|
name: get_countries
|
||||||
type: http
|
type: http
|
||||||
seq: 7
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
7
bruno/b2b_daniel/list/folder.yml
Normal file
7
bruno/b2b_daniel/list/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: list
|
||||||
|
type: folder
|
||||||
|
seq: 3
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: list-products
|
name: list-products
|
||||||
type: http
|
type: http
|
||||||
seq: 4
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: list-users
|
name: list-users
|
||||||
type: http
|
type: http
|
||||||
seq: 5
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
7
bruno/b2b_daniel/menu/folder.yml
Normal file
7
bruno/b2b_daniel/menu/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: menu
|
||||||
|
type: folder
|
||||||
|
seq: 5
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: get-breadcrumb
|
name: get-breadcrumb
|
||||||
type: http
|
type: http
|
||||||
seq: 20
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: get-category-tree
|
name: get-category-tree
|
||||||
type: http
|
type: http
|
||||||
seq: 8
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
7
bruno/b2b_daniel/product-translation/folder.yml
Normal file
7
bruno/b2b_daniel/product-translation/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: product-translation
|
||||||
|
type: folder
|
||||||
|
seq: 2
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: save-product-description
|
name: save-product-description
|
||||||
type: http
|
type: http
|
||||||
seq: 3
|
seq: 25
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: translate-product-description
|
name: translate-product-description
|
||||||
type: http
|
type: http
|
||||||
seq: 2
|
seq: 24
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: create-index
|
name: create-index
|
||||||
type: http
|
type: http
|
||||||
seq: 10
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/meili-search/create-index
|
url: http://localhost:3000/api/v1/restricted/search/create-index
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
7
bruno/b2b_daniel/search/folder.yml
Normal file
7
bruno/b2b_daniel/search/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: search
|
||||||
|
type: folder
|
||||||
|
seq: 6
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: get-indexes
|
name: get-indexes
|
||||||
type: http
|
type: http
|
||||||
seq: 12
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: remove-index
|
name: remove-index
|
||||||
type: http
|
type: http
|
||||||
seq: 11
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: DELETE
|
method: DELETE
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: search
|
name: search
|
||||||
type: http
|
type: http
|
||||||
seq: 13
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/meili-search/search?query=w&limit=4&id_category=0&price_lower_bound=60.0&price_upper_bound=70.0
|
url: http://localhost:3000/api/v1/restricted/search/search?query=w&limit=4&id_category=0&price_lower_bound=60.0&price_upper_bound=70.0
|
||||||
params:
|
params:
|
||||||
- name: query
|
- name: query
|
||||||
value: w
|
value: w
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: test
|
name: test
|
||||||
type: http
|
type: http
|
||||||
seq: 9
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/meili-search/test
|
url: http://localhost:3000/api/v1/restricted/search/test
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
info:
|
info:
|
||||||
name: create-folder
|
name: create-folder
|
||||||
type: http
|
type: http
|
||||||
seq: 24
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/create-folder?path=&name=folder
|
url: http://localhost:3000/api/v1/restricted/storage/create-folder?name=folder
|
||||||
params:
|
params:
|
||||||
- name: path
|
|
||||||
value: ""
|
|
||||||
type: query
|
|
||||||
- name: name
|
- name: name
|
||||||
value: folder
|
value: folder
|
||||||
type: query
|
type: query
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: delete-file
|
name: delete-file
|
||||||
type: http
|
type: http
|
||||||
seq: 25
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: DELETE
|
method: DELETE
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/delete-file?path=/folder/test.txt
|
url: http://localhost:3000/api/v1/restricted/storage/delete-file/folder1/TODO.txt
|
||||||
params:
|
|
||||||
- name: path
|
|
||||||
value: /folder/test.txt
|
|
||||||
type: query
|
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: delete-folder
|
name: delete-folder
|
||||||
type: http
|
type: http
|
||||||
seq: 26
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: DELETE
|
method: DELETE
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/delete-folder?path=/folder/
|
url: http://localhost:3000/api/v1/restricted/storage/delete-folder/folder/
|
||||||
params:
|
|
||||||
- name: path
|
|
||||||
value: /folder/
|
|
||||||
type: query
|
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: download-file
|
name: download-file
|
||||||
type: http
|
type: http
|
||||||
seq: 22
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/download-file?path=/folder1/test.txt
|
url: http://localhost:3000/api/v1/restricted/storage/download-file/folder1/test.xlsx
|
||||||
params:
|
|
||||||
- name: path
|
|
||||||
value: /folder1/test.txt
|
|
||||||
type: query
|
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
7
bruno/b2b_daniel/storage/folder.yml
Normal file
7
bruno/b2b_daniel/storage/folder.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: storage
|
||||||
|
type: folder
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
info:
|
info:
|
||||||
name: list-content
|
name: list-content
|
||||||
type: http
|
type: http
|
||||||
seq: 21
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/list-content?path=/folder1
|
url: http://localhost:3000/api/v1/restricted/storage/list-content/folder1
|
||||||
params:
|
|
||||||
- name: path
|
|
||||||
value: /folder1
|
|
||||||
type: query
|
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
@@ -1,22 +1,18 @@
|
|||||||
info:
|
info:
|
||||||
name: upload-file
|
name: upload-file
|
||||||
type: http
|
type: http
|
||||||
seq: 23
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
url: http://localhost:3000/api/v1/restricted/storage/upload-file?path=folder/
|
url: http://localhost:3000/api/v1/restricted/storage/upload-file/folder1/
|
||||||
params:
|
|
||||||
- name: path
|
|
||||||
value: folder/
|
|
||||||
type: query
|
|
||||||
body:
|
body:
|
||||||
type: multipart-form
|
type: multipart-form
|
||||||
data:
|
data:
|
||||||
- name: document
|
- name: document
|
||||||
type: file
|
type: file
|
||||||
value:
|
value:
|
||||||
- /home/daniel/coding/work/b2b/storage/folder1/test.txt
|
- /home/daniel/TODO.txt
|
||||||
auth: inherit
|
auth: inherit
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
Reference in New Issue
Block a user