move path to params
This commit is contained in:
@@ -27,13 +27,13 @@ func NewStorageHandler() *StorageHandler {
|
||||
func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
handler := NewStorageHandler()
|
||||
|
||||
r.Get("/list-content", handler.ListContent)
|
||||
r.Get("/download-file", handler.DownloadFile)
|
||||
r.Get("/list-content/*", handler.ListContent)
|
||||
r.Get("/download-file/*", handler.DownloadFile)
|
||||
|
||||
r.Post("/upload-file", handler.UploadFile)
|
||||
r.Get("/create-folder", handler.CreateFolder)
|
||||
r.Delete("/delete-file", handler.DeleteFile)
|
||||
r.Delete("/delete-folder", handler.DeleteFolder)
|
||||
r.Post("/upload-file/*", handler.UploadFile)
|
||||
r.Get("/create-folder/*", handler.CreateFolder)
|
||||
r.Delete("/delete-file/*", handler.DeleteFile)
|
||||
r.Delete("/delete-folder/*", handler.DeleteFolder)
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -41,7 +41,7 @@ func StorageHandlerRoutes(r fiber.Router) fiber.Router {
|
||||
// accepted path looks like e.g. "/folder1/" or "folder1"
|
||||
func (h *StorageHandler) ListContent(c fiber.Ctx) error {
|
||||
// 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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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 {
|
||||
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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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.Set("Content-Length", strconv.FormatInt(filesize, 10))
|
||||
c.Set("Content-Type", "application/octet-stream")
|
||||
return c.SendStream(f, int(filesize))
|
||||
}
|
||||
|
||||
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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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 {
|
||||
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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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 {
|
||||
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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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 {
|
||||
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 {
|
||||
return c.Status(responseErrors.GetErrorStatus(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:
|
||||
name: update-choice
|
||||
type: http
|
||||
seq: 6
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: POST
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: add-new-cart
|
||||
type: http
|
||||
seq: 14
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: add-product-to-cart (1)
|
||||
type: http
|
||||
seq: 19
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: add-product-to-cart
|
||||
type: http
|
||||
seq: 18
|
||||
seq: 14
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: change-cart-name
|
||||
type: http
|
||||
seq: 15
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
name: retrieve-cart
|
||||
type: http
|
||||
seq: 17
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: retrieve-carts-info
|
||||
type: http
|
||||
seq: 16
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
name: get_countries
|
||||
type: http
|
||||
seq: 7
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
name: list-products
|
||||
type: http
|
||||
seq: 4
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: list-users
|
||||
type: http
|
||||
seq: 5
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
name: get-breadcrumb
|
||||
type: http
|
||||
seq: 20
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: get-category-tree
|
||||
type: http
|
||||
seq: 8
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
name: save-product-description
|
||||
type: http
|
||||
seq: 3
|
||||
seq: 25
|
||||
|
||||
http:
|
||||
method: POST
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: translate-product-description
|
||||
type: http
|
||||
seq: 2
|
||||
seq: 24
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,11 +1,11 @@
|
||||
info:
|
||||
name: create-index
|
||||
type: http
|
||||
seq: 10
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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
|
||||
|
||||
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:
|
||||
name: get-indexes
|
||||
type: http
|
||||
seq: 12
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
@@ -1,7 +1,7 @@
|
||||
info:
|
||||
name: remove-index
|
||||
type: http
|
||||
seq: 11
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
@@ -1,11 +1,11 @@
|
||||
info:
|
||||
name: search
|
||||
type: http
|
||||
seq: 13
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
- name: query
|
||||
value: w
|
||||
@@ -1,11 +1,11 @@
|
||||
info:
|
||||
name: test
|
||||
type: http
|
||||
seq: 9
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/meili-search/test
|
||||
url: http://localhost:3000/api/v1/restricted/search/test
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
@@ -1,15 +1,12 @@
|
||||
info:
|
||||
name: create-folder
|
||||
type: http
|
||||
seq: 24
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
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:
|
||||
- name: path
|
||||
value: ""
|
||||
type: query
|
||||
- name: name
|
||||
value: folder
|
||||
type: query
|
||||
@@ -1,15 +1,11 @@
|
||||
info:
|
||||
name: delete-file
|
||||
type: http
|
||||
seq: 25
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
url: http://localhost:3000/api/v1/restricted/storage/delete-file?path=/folder/test.txt
|
||||
params:
|
||||
- name: path
|
||||
value: /folder/test.txt
|
||||
type: query
|
||||
url: http://localhost:3000/api/v1/restricted/storage/delete-file/folder1/TODO.txt
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
@@ -1,15 +1,11 @@
|
||||
info:
|
||||
name: delete-folder
|
||||
type: http
|
||||
seq: 26
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: DELETE
|
||||
url: http://localhost:3000/api/v1/restricted/storage/delete-folder?path=/folder/
|
||||
params:
|
||||
- name: path
|
||||
value: /folder/
|
||||
type: query
|
||||
url: http://localhost:3000/api/v1/restricted/storage/delete-folder/folder/
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
@@ -1,15 +1,11 @@
|
||||
info:
|
||||
name: download-file
|
||||
type: http
|
||||
seq: 22
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/storage/download-file?path=/folder1/test.txt
|
||||
params:
|
||||
- name: path
|
||||
value: /folder1/test.txt
|
||||
type: query
|
||||
url: http://localhost:3000/api/v1/restricted/storage/download-file/folder1/test.xlsx
|
||||
auth: inherit
|
||||
|
||||
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:
|
||||
name: list-content
|
||||
type: http
|
||||
seq: 21
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: GET
|
||||
url: http://localhost:3000/api/v1/restricted/storage/list-content?path=/folder1
|
||||
params:
|
||||
- name: path
|
||||
value: /folder1
|
||||
type: query
|
||||
url: http://localhost:3000/api/v1/restricted/storage/list-content/folder1
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
@@ -1,22 +1,18 @@
|
||||
info:
|
||||
name: upload-file
|
||||
type: http
|
||||
seq: 23
|
||||
seq: 1
|
||||
|
||||
http:
|
||||
method: POST
|
||||
url: http://localhost:3000/api/v1/restricted/storage/upload-file?path=folder/
|
||||
params:
|
||||
- name: path
|
||||
value: folder/
|
||||
type: query
|
||||
url: http://localhost:3000/api/v1/restricted/storage/upload-file/folder1/
|
||||
body:
|
||||
type: multipart-form
|
||||
data:
|
||||
- name: document
|
||||
type: file
|
||||
value:
|
||||
- /home/daniel/coding/work/b2b/storage/folder1/test.txt
|
||||
- /home/daniel/TODO.txt
|
||||
auth: inherit
|
||||
|
||||
settings:
|
||||
Reference in New Issue
Block a user