mirror of
https://github.com/Damillora/Shioriko.git
synced 2025-02-23 01:13:39 +00:00
feat: reallow similar images to be uploaded
This commit is contained in:
parent
3d40add1b2
commit
44075dbab9
@ -107,17 +107,6 @@ func uploadBlob(c *gin.Context) {
|
||||
hashSlice := make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(hashSlice, hashInt)
|
||||
|
||||
if len(similarPosts) > 0 {
|
||||
c.JSON(http.StatusOK,
|
||||
models.BlobSimilarResponse{
|
||||
ID: id,
|
||||
Width: width,
|
||||
Height: height,
|
||||
Similar: similarPosts,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
filename := id + filepath.Ext(file.Filename)
|
||||
filePath := filepath.Join(dataDir, folder1, folder2, filename)
|
||||
err = c.SaveUploadedFile(file, filePath)
|
||||
@ -197,11 +186,22 @@ func uploadBlob(c *gin.Context) {
|
||||
|
||||
database.DB.Create(&blob)
|
||||
|
||||
c.JSON(http.StatusOK, models.BlobResponse{
|
||||
ID: id,
|
||||
Width: width,
|
||||
Height: height,
|
||||
PreviewUrl: "/data/" + blob.PreviewFilePath,
|
||||
})
|
||||
if len(similarPosts) > 0 {
|
||||
c.JSON(http.StatusOK,
|
||||
models.BlobSimilarResponse{
|
||||
ID: id,
|
||||
Width: width,
|
||||
Height: height,
|
||||
PreviewUrl: "/data/" + blob.PreviewFilePath,
|
||||
Similar: similarPosts,
|
||||
})
|
||||
} else {
|
||||
c.JSON(http.StatusOK, models.BlobResponse{
|
||||
ID: id,
|
||||
Width: width,
|
||||
Height: height,
|
||||
PreviewUrl: "/data/" + blob.PreviewFilePath,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -22,10 +22,11 @@ type BlobResponse struct {
|
||||
}
|
||||
|
||||
type BlobSimilarResponse struct {
|
||||
ID string `json:"id"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
Similar []PostSimilarityListItem `json:"similar"`
|
||||
ID string `json:"id"`
|
||||
Width int `json:"width"`
|
||||
Height int `json:"height"`
|
||||
PreviewUrl string `json:"previewUrl"`
|
||||
Similar []PostSimilarityListItem `json:"similar"`
|
||||
}
|
||||
type PostPaginationResponse struct {
|
||||
CurrentPage int `json:"currentPage"`
|
||||
|
Loading…
x
Reference in New Issue
Block a user