rf/file upload via form and with metadata

This commit is contained in:
itsscb 2023-10-15 07:52:40 +02:00
parent cf4e84380e
commit 37df328e0c
6 changed files with 118 additions and 73 deletions

View File

@ -29,7 +29,7 @@
"/documents/upload": { "/documents/upload": {
"post": { "post": {
"summary": "Upload Document [only HTTP]", "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", "operationId": "df_UploadDocument",
"responses": { "responses": {
"200": { "200": {
@ -1870,7 +1870,6 @@
"pbUploadDocumentRequest": { "pbUploadDocumentRequest": {
"type": "object", "type": "object",
"example": { "example": {
"file": "10101010101010010100101010010101",
"person_id": "1" "person_id": "1"
}, },
"properties": { "properties": {

View File

@ -3,18 +3,23 @@ package gw
import ( import (
"errors" "errors"
"fmt" "fmt"
"io"
"mime/multipart"
"net/http" "net/http"
"os" "os"
"path"
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/google/uuid"
) )
// type uploadDocumentRequest struct { type uploadDocumentRequest struct {
// PersonID uint64 `json:"person_id"` PersonID uint64 `form:"person_id"`
// MailID uint64 `json:"mail_id"` MailID uint64 `form:"mail_id"`
// } File *multipart.FileHeader `form:"file"`
}
func (server *Server) UploadDocument(ctx *gin.Context) { func (server *Server) UploadDocument(ctx *gin.Context) {
authHeader := ctx.GetHeader("authorization") authHeader := ctx.GetHeader("authorization")
@ -40,10 +45,6 @@ func (server *Server) UploadDocument(ctx *gin.Context) {
return 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") file, err := ctx.FormFile("file")
if err != nil { if err != nil {
ctx.JSON(http.StatusInternalServerError, errorResponse(errors.New("could not parse file"))) 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)) targetDir := filepath.Join("./files", fmt.Sprintf("%d", account.ID))
// var req *uploadDocumentRequest var req *uploadDocumentRequest
// _ = ctx.ShouldBindJSON(&req) err = ctx.ShouldBind(&req)
if err != nil {
ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("failed to parse request")))
return
}
// if req != nil { fileData, err := file.Open()
// if req.MailID <= 0 && req.PersonID <= 0 { if err != nil {
// ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("document can't be assigned to both person_id AND mail_id"))) ctx.JSON(http.StatusBadRequest, errorResponse(errors.New("failed to read file")))
// return return
// } }
// if req.MailID > 0 { if req != nil {
// targetDir = filepath.Join(targetDir, "mail", fmt.Sprintf("%d", req.MailID)) 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")))
// if req.PersonID > 0 { return
// targetDir = filepath.Join(targetDir, "person", fmt.Sprintf("%d", req.PersonID)) }
// }
// }
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 { if _, err := os.Stat(p); err != nil {
err = ctx.SaveUploadedFile(file, p) f, err := os.Create(p)
if err != nil { 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 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 { } else {
ctx.JSON(http.StatusConflict, errorResponse(errors.New("filename already exists"))) ctx.JSON(http.StatusConflict, errorResponse(errors.New("filename already exists")))
return return

View File

@ -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, 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, 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, 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, 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, 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, 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, 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, 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, 0x48, 0x01, 0x52, 0x06, 0x6d, 0x61, 0x69, 0x6c, 0x49, 0x64, 0x88, 0x01, 0x01, 0x3a, 0x5c, 0x92,
0x92, 0x41, 0x85, 0x01, 0x0a, 0x42, 0x2a, 0x1a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x41, 0x59, 0x0a, 0x42, 0x2a, 0x1a, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75,
0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d,
0x50, 0x5d, 0x32, 0x1d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x61, 0x20, 0x44, 0x6f, 0x63, 0x32, 0x1d, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x20, 0x61, 0x20, 0x44, 0x6f, 0x63, 0x75, 0x6d,
0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x65, 0x6e, 0x74, 0x20, 0x5b, 0x6f, 0x6e, 0x6c, 0x79, 0x20, 0x48, 0x54, 0x54, 0x50, 0x5d, 0xd2,
0x5d, 0xd2, 0x01, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x32, 0x3f, 0x7b, 0x22, 0x66, 0x69, 0x6c, 0x65, 0x01, 0x04, 0x66, 0x69, 0x6c, 0x65, 0x32, 0x13, 0x7b, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e,
0x22, 0x3a, 0x20, 0x22, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x5f, 0x69, 0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x20, 0x7d, 0x42, 0x0c, 0x0a, 0x0a, 0x5f,
0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x31, 0x30, 0x31, 0x30, 0x31, 0x30, 0x30, 0x31, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x61,
0x30, 0x31, 0x30, 0x31, 0x22, 0x2c, 0x20, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x69, 0x6c, 0x5f, 0x69, 0x64, 0x22, 0x62, 0x0a, 0x16, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44,
0x64, 0x22, 0x3a, 0x20, 0x22, 0x31, 0x22, 0x20, 0x7d, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x70, 0x65, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x6d, 0x61, 0x69, 0x6c, 0x28, 0x0a, 0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28,
0x5f, 0x69, 0x64, 0x22, 0x62, 0x0a, 0x16, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x0b, 0x32, 0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52,
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, 0x3a, 0x1e, 0x92, 0x41, 0x1b, 0x0a, 0x19,
0x08, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x2a, 0x17, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74,
0x0c, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x08, 0x64, 0x20, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x19, 0x5a, 0x17, 0x67, 0x69, 0x74,
0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x3a, 0x1e, 0x92, 0x41, 0x1b, 0x0a, 0x19, 0x2a, 0x17, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64,
0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x44, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x52, 0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
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 ( var (

View File

@ -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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 0x22, 0x20, 0x2d, 0x46, 0x20, 0x22, 0x70, 0x65, 0x72, 0x73, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x3d,
0x72, 0x55, 0x52, 0x49, 0x7d, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x2f, 0x31, 0x22, 0x20, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x7b, 0x73, 0x65, 0x72, 0x76,
0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x60, 0x60, 0x60, 0x62, 0x10, 0x0a, 0x0e, 0x0a, 0x0a, 0x65, 0x72, 0x55, 0x52, 0x49, 0x7d, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x73,
0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4, 0x93, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x22, 0x60, 0x60, 0x60, 0x62, 0x10, 0x0a, 0x0e, 0x0a,
0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x0a, 0x42, 0x65, 0x61, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x00, 0x82, 0xd3, 0xe4,
0x73, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x07, 0x92, 0x41, 0x04, 0x12, 0x02, 0x64, 0x93, 0x02, 0x16, 0x3a, 0x01, 0x2a, 0x22, 0x11, 0x2f, 0x64, 0x6f, 0x63, 0x75, 0x6d, 0x65, 0x6e,
0x66, 0x42, 0xb0, 0x01, 0x92, 0x41, 0x93, 0x01, 0x12, 0x44, 0x0a, 0x06, 0x64, 0x66, 0x20, 0x41, 0x74, 0x73, 0x2f, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x1a, 0x07, 0x92, 0x41, 0x04, 0x12, 0x02,
0x50, 0x49, 0x22, 0x35, 0x0a, 0x06, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x12, 0x1c, 0x68, 0x74, 0x64, 0x66, 0x42, 0xb0, 0x01, 0x92, 0x41, 0x93, 0x01, 0x12, 0x44, 0x0a, 0x06, 0x64, 0x66, 0x20,
0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x41, 0x50, 0x49, 0x22, 0x35, 0x0a, 0x06, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x12, 0x1c, 0x68,
0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x1a, 0x0d, 0x64, 0x65, 0x76, 0x40, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2e, 0x64, 0x65, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x2a, 0x02, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x66, 0x1a, 0x0d, 0x64, 0x65, 0x76,
0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2f, 0x40, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2e, 0x64, 0x65, 0x32, 0x03, 0x31, 0x2e, 0x30, 0x2a,
0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x02, 0x01, 0x02, 0x32, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x5a, 0x23, 0x0a, 0x21, 0x0a, 0x0a, 0x42, 0x65, 0x61, 0x72, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x3a, 0x10, 0x61, 0x70, 0x70, 0x6c, 0x69, 0x63, 0x61, 0x74, 0x69,
0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x13, 0x08, 0x02, 0x1a, 0x0d, 0x41, 0x75, 0x74, 0x68, 0x6f, 0x6e, 0x2f, 0x6a, 0x73, 0x6f, 0x6e, 0x5a, 0x23, 0x0a, 0x21, 0x0a, 0x0a, 0x42, 0x65, 0x61,
0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x02, 0x5a, 0x17, 0x67, 0x69, 0x74, 0x72, 0x65, 0x72, 0x41, 0x75, 0x74, 0x68, 0x12, 0x13, 0x08, 0x02, 0x1a, 0x0d, 0x41, 0x75, 0x74,
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x74, 0x73, 0x73, 0x63, 0x62, 0x2f, 0x64, 0x68, 0x6f, 0x72, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x02, 0x5a, 0x17, 0x67, 0x69,
0x66, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 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{}{ var file_service_df_proto_goTypes = []interface{}{

View File

@ -17,7 +17,7 @@ message UploadDocumentRequest {
"file" "file"
]; ];
}; };
example: "{\"file\": \"10101010101010010100101010010101\", \"person_id\": \"1\" }"; example: "{\"person_id\": \"1\" }";
}; };
bytes file = 1; bytes file = 1;
optional uint64 person_id = 2; optional uint64 person_id = 2;

View File

@ -340,7 +340,7 @@ option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
}; };
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Upload Document [only HTTP]" 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: {
security_requirement: { security_requirement: {
key: "BearerAuth"; key: "BearerAuth";