• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

a1y-developer / doc-formatter / 20615518441

31 Dec 2025 08:45AM UTC coverage: 65.274% (-2.5%) from 67.802%
20615518441

Pull #23

github

web-flow
Merge 927ec1ce0 into 3f7df65bc
Pull Request #23: feat: upload to s3

293 of 507 new or added lines in 30 files covered. (57.79%)

3 existing lines in 2 files now uncovered.

906 of 1388 relevant lines covered (65.27%)

0.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.89
/internal/gateway/handler/storage/storage_handler.go
1
package storage
2

3
import (
4
        "io"
5
        "net/http"
6

7
        "github.com/a1y/doc-formatter/internal/gateway/domain/request"
8
        "github.com/gin-gonic/gin"
9
)
10

11
// UploadFile godoc
12
//
13
//        @Summary                Upload file
14
//        @Description        Upload a file for a user
15
//        @Tags                        Storage
16
//        @Accept                        multipart/form-data
17
//        @Produce                json
18
//        @Param                        user_id        formData        string        true        "User ID (UUID)"
19
//        @Param                        file        formData        file        true        "File to upload"
20
//        @Success                201                {object}        response.UploadFileResponse
21
//        @Failure                400                {object}        map[string]string
22
//        @Failure                500                {object}        map[string]string
23
//        @Router                        /api/v1/storage/upload [post]
24
func (h *StorageHandler) UploadFile(c *gin.Context) {
1✔
25
        var req request.UploadFileRequest
1✔
26
        if err := c.ShouldBind(&req); err != nil {
2✔
27
                c.JSON(http.StatusBadRequest, gin.H{"error": err.Error()})
1✔
28
                return
1✔
29
        }
1✔
30

31
        file, header, err := c.Request.FormFile("file")
1✔
32
        if err != nil {
2✔
33
                c.JSON(http.StatusBadRequest, gin.H{"error": "file is required"})
1✔
34
                return
1✔
35
        }
1✔
36
        defer file.Close()
1✔
37

1✔
38
        fileBytes, err := io.ReadAll(file)
1✔
39
        if err != nil {
1✔
NEW
40
                c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
×
NEW
41
                return
×
NEW
42
        }
×
43

44
        resp, err := h.storageManager.UploadFile(c.Request.Context(), req.UserID, header.Filename, int64(len(fileBytes)), fileBytes)
1✔
45
        if err != nil {
2✔
46
                c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
1✔
47
                return
1✔
48
        }
1✔
49

50
        c.JSON(http.StatusCreated, gin.H{
1✔
51
                "file_id":   resp.FileID,
1✔
52
                "file_name": resp.FileName,
1✔
53
        })
1✔
54
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc