diff --git a/bff/doc/swagger/df.swagger.json b/bff/doc/swagger/df.swagger.json index e8e8896..2da7011 100644 --- a/bff/doc/swagger/df.swagger.json +++ b/bff/doc/swagger/df.swagger.json @@ -29,7 +29,7 @@ "/documents/upload": { "post": { "summary": "Upload Document [only HTTP]", - "description": "Testing via swagger is not possible. Try ```curl -X POST -H \"Authorization: Bearer {token}\" -F \"file=@/path/to/file\" \"http://{serverURI}/documents/upload\"```", + "description": "Testing via swagger is not possible. Try ```curl -X POST -H \"Authorization: Bearer {token}\" -F \"file=@/path/to/file\" -F \"person_id=1\" \"http://{serverURI}/documents/upload\"```", "operationId": "df_UploadDocument", "responses": { "200": { @@ -1870,7 +1870,6 @@ "pbUploadDocumentRequest": { "type": "object", "example": { - "file": "10101010101010010100101010010101", "person_id": "1" }, "properties": { diff --git a/bff/gw/document.go b/bff/gw/document.go index 34f2b5c..2b13ec4 100644 --- a/bff/gw/document.go +++ b/bff/gw/document.go @@ -3,18 +3,23 @@ package gw import ( "errors" "fmt" + "io" + "mime/multipart" "net/http" "os" + "path" "path/filepath" "strings" "github.com/gin-gonic/gin" + "github.com/google/uuid" ) -// type uploadDocumentRequest struct { -// PersonID uint64 `json:"person_id"` -// MailID uint64 `json:"mail_id"` -// } +type uploadDocumentRequest struct { + PersonID uint64 `form:"person_id"` + MailID uint64 `form:"mail_id"` + File *multipart.FileHeader `form:"file"` +} func (server *Server) UploadDocument(ctx *gin.Context) { authHeader := ctx.GetHeader("authorization") @@ -40,10 +45,6 @@ func (server *Server) UploadDocument(ctx *gin.Context) { return } - // TODO: FileUpload with POST-Values - // bodyData, _ := io.ReadAll(ctx.Request.Body) - // slog.Info("Document", slog.String("body", fmt.Sprintf("%#v", string(bodyData)))) - file, err := ctx.FormFile("file") if err != nil { ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not parse file"))) @@ -52,32 +53,79 @@ func (server *Server) UploadDocument(ctx *gin.Context) { targetDir := filepath.Join("./files", fmt.Sprintf("%d", account.ID)) - // var req *uploadDocumentRequest - // _ = ctx.ShouldBindJSON(&req) + var req *uploadDocumentRequest + err = ctx.ShouldBind(&req) + if err != nil { + ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("failed to parse request"))) + return + } - // if req != nil { - // if req.MailID <= 0 && req.PersonID <= 0 { - // ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("document can't be assigned to both person_id AND mail_id"))) - // return - // } + fileData, err := file.Open() + if err != nil { + ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("failed to read file"))) + return + } - // if req.MailID > 0 { - // targetDir = filepath.Join(targetDir, "mail", fmt.Sprintf("%d", req.MailID)) - // } - // if req.PersonID > 0 { - // targetDir = filepath.Join(targetDir, "person", fmt.Sprintf("%d", req.PersonID)) - // } - // } + if req != nil { + if req.MailID <= 0 && req.PersonID <= 0 { + ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("document can't be assigned to both person_id AND mail_id"))) + return + } - p := filepath.Join(targetDir, file.Filename) + if req.MailID > 0 { + _, err := server.store.GetMail(ctx, req.MailID) + if err != nil { + ctx.JSON(http.StatusNotFound, errorResponse(errors.New("mail not found"))) + return + + } + targetDir = filepath.Join(targetDir, "mail", fmt.Sprintf("%d", req.MailID)) + } + if req.PersonID > 0 { + _, err := server.store.GetPerson(ctx, req.PersonID) + if err != nil { + ctx.JSON(http.StatusNotFound, errorResponse(errors.New("person not found"))) + return + + } + targetDir = filepath.Join(targetDir, "person", fmt.Sprintf("%d", req.PersonID)) + } + } + + uid, err := uuid.NewUUID() + if err != nil { + ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not generate file name"))) + return + } + + if _, err := os.Stat(targetDir); err != nil { + err = os.MkdirAll(targetDir, 0755) + if err != nil { + ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not create directory structure"))) + return + } + + } + + p := filepath.Join(targetDir, uid.String()+path.Ext(file.Filename)) if _, err := os.Stat(p); err != nil { - err = ctx.SaveUploadedFile(file, p) + f, err := os.Create(p) if err != nil { - ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not save file"))) + ctx.JSON(http.StatusInternalServerError, errorResponse(fmt.Errorf("could not create file: %v", err))) return - } + + _, err = io.Copy(f, fileData) + if err != nil { + ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not write file"))) + return + } + // err = ctx.SaveUploadedFile(file, p) + // if err != nil { + // ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not save file"))) + // return + // } } else { ctx.JSON(http.StatusConflict, errorResponse(errors.New("filename already exists"))) return diff --git a/bff/pb/rpc_upload_document.pb.go b/bff/pb/rpc_upload_document.pb.go index 654a21a..3295630 100644 --- a/bff/pb/rpc_upload_document.pb.go +++ b/bff/pb/rpc_upload_document.pb.go @@ -140,32 +140,29 @@ var file_rpc_upload_document_proto_rawDesc = []byte{ 0x61, 0x70, 0x69, 0x76, 0x32, 0x2f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x61, 0x6e, 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0e, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, - 0x91, 0x02, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, + 0xe3, 0x01, 0x0a, 0x15, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x12, 0x20, 0x0a, 0x09, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x48, 0x00, 0x52, 0x08, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1c, 0x0a, 0x07, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, - 0x48, 0x01, 0x52, 0x06, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x89, 0x01, - 0x92, 0x41, 0x85, 0x01, 0x0a, 0x42, 0x2a, 0x1a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, - 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, - 0x50, 0x5d, 0x32, 0x1d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x61, 0x20, 0x44, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, - 0x5d, 0xd2, 0x01, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x32, 0x3f, 0x7b, 0x22, 0x66, 0x69, 0x6c, 0x65, - 0x22, 0x3a, 0x20, 0x22, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, - 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x31, - 0x30, 0x31, 0x30, 0x31, 0x22, 0x2c, 0x20, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, - 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x20, 0x7d, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x65, - 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x61, 0x69, 0x6c, - 0x5f, 0x69, 0x64, 0x22, 0x62, 0x0a, 0x16, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, - 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, - 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x64, - 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x3a, 0x1e, 0x92, 0x41, 0x1b, 0x0a, 0x19, 0x2a, 0x17, - 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x52, - 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x68, 0x75, - 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x2f, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x48, 0x01, 0x52, 0x06, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x5c, 0x92, + 0x41, 0x59, 0x0a, 0x42, 0x2a, 0x1a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, + 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d, + 0x32, 0x1d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x61, 0x20, 0x44, 0x6f, 0x63, 0x75, 0x6d, + 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d, 0xd2, + 0x01, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x32, 0x13, 0x7b, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, + 0x5f, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x20, 0x7d, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, + 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x61, + 0x69, 0x6c, 0x5f, 0x69, 0x64, 0x22, 0x62, 0x0a, 0x16, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, + 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x28, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, + 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x3a, 0x1e, 0x92, 0x41, 0x1b, 0x0a, 0x19, + 0x2a, 0x17, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, + 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74, + 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, + 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/bff/pb/service_df.pb.go b/bff/pb/service_df.pb.go index 95e0f84..7aca2d0 100644 --- a/bff/pb/service_df.pb.go +++ b/bff/pb/service_df.pb.go @@ -64,7 +64,7 @@ var file_service_df_proto_rawDesc = []byte{ 0x6c, 0x6f, 0x67, 0x5f, 0x62, 0x79, 0x5f, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x72, 0x70, 0x63, 0x5f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x5f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x32, 0xbd, 0x19, 0x0a, 0x02, 0x64, 0x66, 0x12, 0x42, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, + 0x6f, 0x32, 0xce, 0x19, 0x0a, 0x02, 0x64, 0x66, 0x12, 0x42, 0x0a, 0x05, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x12, 0x10, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x14, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x0e, 0x3a, 0x01, @@ -247,14 +247,14 @@ var file_service_df_proto_rawDesc = []byte{ 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x2e, 0x12, 0x2c, 0x2f, 0x76, 0x31, 0x2f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x5f, 0x6c, 0x6f, 0x67, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x5f, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x73, 0x5f, 0x6c, 0x6f, 0x67, - 0x2f, 0x7b, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0xb9, 0x02, 0x0a, + 0x2f, 0x7b, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x7d, 0x12, 0xca, 0x02, 0x0a, 0x0e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x19, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, - 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xef, 0x01, 0x92, 0x41, 0xcf, 0x01, 0x12, 0x1b, 0x55, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x80, 0x02, 0x92, 0x41, 0xe0, 0x01, 0x12, 0x1b, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, - 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d, 0x1a, 0x9d, 0x01, 0x54, 0x65, 0x73, + 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d, 0x1a, 0xae, 0x01, 0x54, 0x65, 0x73, 0x74, 0x69, 0x6e, 0x67, 0x20, 0x76, 0x69, 0x61, 0x20, 0x73, 0x77, 0x61, 0x67, 0x67, 0x65, 0x72, 0x20, 0x69, 0x73, 0x20, 0x6e, 0x6f, 0x74, 0x20, 0x70, 0x6f, 0x73, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x2e, 0x20, 0x54, 0x72, 0x79, 0x20, 0x60, 0x60, 0x60, 0x63, 0x75, 0x72, 0x6c, 0x20, 0x2d, 0x58, @@ -262,24 +262,25 @@ var file_service_df_proto_rawDesc = []byte{ 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x20, 0x7b, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x7d, 0x22, 0x20, 0x2d, 0x46, 0x20, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x3d, 0x40, 0x2f, 0x70, 0x61, 0x74, 0x68, 0x2f, 0x74, 0x6f, 0x2f, 0x66, 0x69, 0x6c, 0x65, - 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, 0x65, - 0x72, 0x55, 0x52, 0x49, 0x7d, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, - 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x60, 0x60, 0x60, 0x62, 0x10, 0x0a, 0x0e, 0x0a, 0x0a, - 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, - 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, - 0x73, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x07, 0x92, 0x41, 0x04, 0x12, 0x02, 0x64, - 0x66, 0x42, 0xb0, 0x01, 0x92, 0x41, 0x93, 0x01, 0x12, 0x44, 0x0a, 0x06, 0x64, 0x66, 0x20, 0x41, - 0x50, 0x49, 0x22, 0x35, 0x0a, 0x06, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x12, 0x1c, 0x68, 0x74, - 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, - 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x1a, 0x0d, 0x64, 0x65, 0x76, 0x40, - 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2e, 0x64, 0x65, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x2a, 0x02, - 0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, - 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, - 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x5a, 0x23, 0x0a, 0x21, 0x0a, 0x0a, 0x42, 0x65, 0x61, 0x72, - 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x13, 0x08, 0x02, 0x1a, 0x0d, 0x41, 0x75, 0x74, 0x68, - 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x02, 0x5a, 0x17, 0x67, 0x69, 0x74, - 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, - 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x20, 0x2d, 0x46, 0x20, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x3d, + 0x31, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76, + 0x65, 0x72, 0x55, 0x52, 0x49, 0x7d, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, + 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x60, 0x60, 0x60, 0x62, 0x10, 0x0a, 0x0e, 0x0a, + 0x0a, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, + 0x74, 0x73, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x07, 0x92, 0x41, 0x04, 0x12, 0x02, + 0x64, 0x66, 0x42, 0xb0, 0x01, 0x92, 0x41, 0x93, 0x01, 0x12, 0x44, 0x0a, 0x06, 0x64, 0x66, 0x20, + 0x41, 0x50, 0x49, 0x22, 0x35, 0x0a, 0x06, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x12, 0x1c, 0x68, + 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x1a, 0x0d, 0x64, 0x65, 0x76, + 0x40, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2e, 0x64, 0x65, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x2a, + 0x02, 0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, + 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x5a, 0x23, 0x0a, 0x21, 0x0a, 0x0a, 0x42, 0x65, 0x61, + 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x13, 0x08, 0x02, 0x1a, 0x0d, 0x41, 0x75, 0x74, + 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x02, 0x5a, 0x17, 0x67, 0x69, + 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, + 0x64, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var file_service_df_proto_goTypes = []interface{}{ diff --git a/bff/proto/rpc_upload_document.proto b/bff/proto/rpc_upload_document.proto index 07059c1..76da119 100644 --- a/bff/proto/rpc_upload_document.proto +++ b/bff/proto/rpc_upload_document.proto @@ -17,7 +17,7 @@ message UploadDocumentRequest { "file" ]; }; - example: "{\"file\": \"10101010101010010100101010010101\", \"person_id\": \"1\" }"; + example: "{\"person_id\": \"1\" }"; }; bytes file = 1; optional uint64 person_id = 2; diff --git a/bff/proto/service_df.proto b/bff/proto/service_df.proto index c18f68b..47133ae 100644 --- a/bff/proto/service_df.proto +++ b/bff/proto/service_df.proto @@ -340,7 +340,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = { }; option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { summary: "Upload Document [only HTTP]" - description: "Testing via swagger is not possible. Try ```curl -X POST -H \"Authorization: Bearer {token}\" -F \"file=@/path/to/file\" \"http://{serverURI}/documents/upload\"```" + description: "Testing via swagger is not possible. Try ```curl -X POST -H \"Authorization: Bearer {token}\" -F \"file=@/path/to/file\" -F \"person_id=1\" \"http://{serverURI}/documents/upload\"```" security: { security_requirement: { key: "BearerAuth";