feat: add file deduplication and hash checking for uploads
- Implemented SHA-256 hashing for uploaded files to enable deduplication. - Added CheckHash method to verify if a file with the same hash already exists. - Updated Upload method to reuse existing media assets if a duplicate is found. - Introduced a new hash column in the media_assets table to store file hashes. - Enhanced the upload process to include progress tracking and hash calculation. - Modified frontend to check for existing files before uploading and to show upload progress. - Added vuedraggable for drag-and-drop functionality in the content editing view.
This commit is contained in:
@@ -35,7 +35,7 @@ func (c *Common) Upload(
|
||||
if form != nil {
|
||||
val = form.Type
|
||||
}
|
||||
return services.Common.Upload(ctx.Context(), user.ID, file, val)
|
||||
return services.Common.Upload(ctx, user.ID, file, val)
|
||||
}
|
||||
|
||||
// Get options (enums)
|
||||
@@ -50,3 +50,19 @@ func (c *Common) Upload(
|
||||
func (c *Common) GetOptions(ctx fiber.Ctx) (*dto.OptionsResponse, error) {
|
||||
return services.Common.Options(ctx)
|
||||
}
|
||||
|
||||
// Check file hash for deduplication
|
||||
//
|
||||
// @Router /v1/upload/check [get]
|
||||
// @Summary Check hash
|
||||
// @Description Check if file hash exists
|
||||
// @Tags Common
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param hash query string true "File Hash"
|
||||
// @Success 200 {object} dto.UploadResult
|
||||
// @Bind user local key(__ctx_user)
|
||||
// @Bind hash query
|
||||
func (c *Common) CheckHash(ctx fiber.Ctx, user *models.User, hash string) (*dto.UploadResult, error) {
|
||||
return services.Common.CheckHash(ctx, user.ID, hash)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user