From 271b1a223029717bbe98423154e616d25a063b7e Mon Sep 17 00:00:00 2001 From: rogeecn Date: Sat, 22 Mar 2025 17:02:06 +0800 Subject: [PATCH] feat: fix issues --- app/http/uploads.go | 3 +-- config.toml | 1 + test.http | 15 +++++++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/http/uploads.go b/app/http/uploads.go index 1e7d089..7708f16 100644 --- a/app/http/uploads.go +++ b/app/http/uploads.go @@ -20,7 +20,7 @@ type uploads struct { } func (up *uploads) storagePath() string { - return filepath.Join(up.app.StoragePath, "uploads/tmp") + return filepath.Join(up.app.StoragePath, "uploads") } type UploadChunk struct { @@ -32,7 +32,6 @@ type UploadFileInfo struct { Md5 string `json:"md5"` Filename string `json:"filename"` Mime string `json:"mime"` - Size int64 `json:"size"` Chunks int `json:"chunks"` } diff --git a/config.toml b/config.toml index b305432..ec4c927 100644 --- a/config.toml +++ b/config.toml @@ -1,6 +1,7 @@ [App] Mode = "development" BaseURI = "baseURI" +StoragePath = "/Users/rogee/Projects/self/quyun/fixtures" [Http] Port = 8088 diff --git a/test.http b/test.http index 1ab7c31..dbf3aaa 100644 --- a/test.http +++ b/test.http @@ -1,7 +1,7 @@ @host=http://localhost:8088 @md5=959e5310105c96e653f10b74e5bdc36b -@idx=0 +@idx=9 ### upload chunk POST {{host}}/v1/uploads/{{md5}}/chunks/{{idx}} HTTP/1.1 Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW @@ -10,10 +10,21 @@ Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0g Content-Disposition: form-data; name="file"; filename="0" Content-Type: application/octet-stream -< ./fixtures/files/0 +< ./fixtures/files/{{idx}} ------WebKitFormBoundary7MA4YWxkTrZu0gW-- +### complete upload +POST {{host}}/v1/uploads/{{md5}}/complete HTTP/1.1 +Content-Type: application/json + +{ + "md5": "{{md5}}", + "filename": "camera.mp4", + "mime": "video/mp4", + "chunks": 30 +} + ### get medias GET {{host}}/v1/medias HTTP/1.1 Content-Type: application/json \ No newline at end of file