Skip to content
Snippets Groups Projects
Verified Commit a175dbd6 authored by Ernesto Rico Schmidt's avatar Ernesto Rico Schmidt
Browse files

feat: upload a file for a show now get the showId from the database

parent 08e1d48a
No related branches found
No related tags found
No related merge requests found
......@@ -385,7 +385,6 @@ func getFlowJSParameterFromQuery(r *http.Request) (id string, chunk, totalChunks
// @Summary Upload file content
// @Description Uploads file content via flow.js. Only available if file was created using SourceURI set to upload://-type and file import state is running.
// @Accept mpfd
// @Param showID query int true "ID of the show"
// @Param id path int true "ID of the file"
// @Success 200 {object} nil
// @Failure 400 {object} ErrorResponse
......@@ -394,17 +393,19 @@ func getFlowJSParameterFromQuery(r *http.Request) (id string, chunk, totalChunks
// @Failure 500 {object} ErrorResponse
// @Router /api/v1/upload/{id} [post]
func (api *API) UploadFileFlowJS(c *gin.Context) {
showID, err := getShowID(c)
id, err := idFromString(c.Param("file-id"))
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid showId: " + err.Error()})
}
if authorized, _ := authorizeRequestForShow(c, showID); !authorized {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid file-id: " + err.Error()})
return
}
id, err := idFromString(c.Param("file-id"))
// get the showId for this file from the database
showId, err := api.store.GetFileShowID(id)
if err != nil {
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid file-id: " + err.Error()})
c.JSON(http.StatusBadRequest, ErrorResponse{Error: "invalid showId: " + err.Error()})
}
if authorized, _ := authorizeRequestForShow(c, showId); !authorized {
return
}
flowId, chunk, totalChunks, chunkSize, totalSize, data, err := getFlowJSParameterFromMultipart(c.Request)
......@@ -413,7 +414,7 @@ func (api *API) UploadFileFlowJS(c *gin.Context) {
return
}
job, err := api.importer.GetJob(showID, id)
job, err := api.importer.GetJob(showId, id)
if err != nil {
sendError(c, err)
return
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment