✨ Make it more implementable
This commit is contained in:
parent
73b39a4fb5
commit
37c47f9839
19
.idea/workspace.xml
generated
19
.idea/workspace.xml
generated
@ -4,19 +4,12 @@
|
|||||||
<option name="autoReloadType" value="ALL" />
|
<option name="autoReloadType" value="ALL" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":sparkles: Un-public indexable & select by pools">
|
<list default="true" id="18dd0d68-b4b8-40db-9734-9119b5c848bd" name="更改" comment=":sparkles: Multipart file upload">
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_direct_api.go" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/pkg/internal/services/merger.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/models/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/models/attachments.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/attachments_api.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/up_multipart_api.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/server/api/index.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/server/api/index.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/analyzer.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/attachments.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/attachments.go" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/pkg/internal/services/merger.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/merger.go" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/random_id.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/random_id.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/recycler.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/recycler.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/internal/services/uploader.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/internal/services/uploader.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/pkg/main.go" beforeDir="false" afterPath="$PROJECT_DIR$/pkg/main.go" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/settings.toml" beforeDir="false" afterPath="$PROJECT_DIR$/settings.toml" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
@ -128,7 +121,6 @@
|
|||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value=":truck: Update url mapping" />
|
|
||||||
<MESSAGE value=":bug: Fix uuid duplicate when link exists" />
|
<MESSAGE value=":bug: Fix uuid duplicate when link exists" />
|
||||||
<MESSAGE value=" :sparkles: Add health check" />
|
<MESSAGE value=" :sparkles: Add health check" />
|
||||||
<MESSAGE value=":arrow_up: Upgrade Passport and use Hyper SDK" />
|
<MESSAGE value=":arrow_up: Upgrade Passport and use Hyper SDK" />
|
||||||
@ -153,7 +145,8 @@
|
|||||||
<MESSAGE value=":boom: Use attachment rid instead of primary key when create" />
|
<MESSAGE value=":boom: Use attachment rid instead of primary key when create" />
|
||||||
<MESSAGE value=":bug: Fix crash on maintain cache" />
|
<MESSAGE value=":bug: Fix crash on maintain cache" />
|
||||||
<MESSAGE value=":sparkles: Un-public indexable & select by pools" />
|
<MESSAGE value=":sparkles: Un-public indexable & select by pools" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Un-public indexable & select by pools" />
|
<MESSAGE value=":sparkles: Multipart file upload" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value=":sparkles: Multipart file upload" />
|
||||||
</component>
|
</component>
|
||||||
<component name="VgoProject">
|
<component name="VgoProject">
|
||||||
<settings-migrated>true</settings-migrated>
|
<settings-migrated>true</settings-migrated>
|
||||||
|
@ -25,7 +25,6 @@ type Attachment struct {
|
|||||||
Alternative string `json:"alt"`
|
Alternative string `json:"alt"`
|
||||||
MimeType string `json:"mimetype"`
|
MimeType string `json:"mimetype"`
|
||||||
HashCode string `json:"hash"`
|
HashCode string `json:"hash"`
|
||||||
UserHash *string `json:"user_hash"`
|
|
||||||
Destination AttachmentDst `json:"destination"`
|
Destination AttachmentDst `json:"destination"`
|
||||||
RefCount int `json:"ref_count"`
|
RefCount int `json:"ref_count"`
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
|
|||||||
var data struct {
|
var data struct {
|
||||||
Pool string `json:"pool" validate:"required"`
|
Pool string `json:"pool" validate:"required"`
|
||||||
Size int64 `json:"size" validate:"required"`
|
Size int64 `json:"size" validate:"required"`
|
||||||
Hash string `json:"hash" validate:"required"`
|
|
||||||
Alternative string `json:"alt"`
|
Alternative string `json:"alt"`
|
||||||
MimeType string `json:"mimetype"`
|
MimeType string `json:"mimetype"`
|
||||||
Metadata map[string]any `json:"metadata"`
|
Metadata map[string]any `json:"metadata"`
|
||||||
@ -43,7 +42,6 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
metadata, err := services.NewAttachmentPlaceholder(database.C, user, models.Attachment{
|
metadata, err := services.NewAttachmentPlaceholder(database.C, user, models.Attachment{
|
||||||
UserHash: &data.Hash,
|
|
||||||
Alternative: data.Alternative,
|
Alternative: data.Alternative,
|
||||||
MimeType: data.MimeType,
|
MimeType: data.MimeType,
|
||||||
Metadata: data.Metadata,
|
Metadata: data.Metadata,
|
||||||
@ -57,7 +55,10 @@ func createAttachmentMultipartPlaceholder(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
return fiber.NewError(fiber.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.JSON(metadata)
|
return c.JSON(fiber.Map{
|
||||||
|
"chunk_size": viper.GetInt64("performance.file_chunk_size"),
|
||||||
|
"meta": metadata,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadAttachmentMultipart(c *fiber.Ctx) error {
|
func uploadAttachmentMultipart(c *fiber.Ctx) error {
|
||||||
|
@ -99,6 +99,14 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
|
|
||||||
var start time.Time
|
var start time.Time
|
||||||
|
|
||||||
|
if len(file.HashCode) == 0 {
|
||||||
|
if hash, err := HashAttachment(file); err != nil {
|
||||||
|
return err
|
||||||
|
} else {
|
||||||
|
file.HashCode = hash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do analyze jobs
|
// Do analyze jobs
|
||||||
if !file.IsAnalyzed || len(file.HashCode) == 0 {
|
if !file.IsAnalyzed || len(file.HashCode) == 0 {
|
||||||
destMap := viper.GetStringMap("destinations.temporary")
|
destMap := viper.GetStringMap("destinations.temporary")
|
||||||
@ -158,12 +166,6 @@ func AnalyzeAttachment(file models.Attachment) error {
|
|||||||
"color_space": stream.ColorSpace,
|
"color_space": stream.ColorSpace,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if hash, err := HashAttachment(file); err != nil {
|
|
||||||
return err
|
|
||||||
} else {
|
|
||||||
file.HashCode = hash
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tx := database.C.Begin()
|
tx := database.C.Begin()
|
||||||
|
@ -44,5 +44,7 @@ func MergeFileChunks(meta models.Attachment, arrange []string) (models.Attachmen
|
|||||||
meta.IsUploaded = true
|
meta.IsUploaded = true
|
||||||
database.C.Save(&meta)
|
database.C.Save(&meta)
|
||||||
|
|
||||||
|
PublishAnalyzeTask(meta)
|
||||||
|
|
||||||
return meta, nil
|
return meta, nil
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ access_token_duration = 300
|
|||||||
refresh_token_duration = 2592000
|
refresh_token_duration = 2592000
|
||||||
|
|
||||||
[performance]
|
[performance]
|
||||||
file_chunk_size = 5242880
|
file_chunk_size = 26214400
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
dsn = "host=localhost user=postgres password=password dbname=hy_paperclip port=5432 sslmode=disable"
|
dsn = "host=localhost user=postgres password=password dbname=hy_paperclip port=5432 sslmode=disable"
|
||||||
|
Loading…
Reference in New Issue
Block a user