mirror of
https://github.com/Damillora/Shioriko.git
synced 2025-02-23 09:23:38 +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)
|
hashSlice := make([]byte, 8)
|
||||||
binary.LittleEndian.PutUint64(hashSlice, hashInt)
|
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)
|
filename := id + filepath.Ext(file.Filename)
|
||||||
filePath := filepath.Join(dataDir, folder1, folder2, filename)
|
filePath := filepath.Join(dataDir, folder1, folder2, filename)
|
||||||
err = c.SaveUploadedFile(file, filePath)
|
err = c.SaveUploadedFile(file, filePath)
|
||||||
@ -197,11 +186,22 @@ func uploadBlob(c *gin.Context) {
|
|||||||
|
|
||||||
database.DB.Create(&blob)
|
database.DB.Create(&blob)
|
||||||
|
|
||||||
c.JSON(http.StatusOK, models.BlobResponse{
|
if len(similarPosts) > 0 {
|
||||||
ID: id,
|
c.JSON(http.StatusOK,
|
||||||
Width: width,
|
models.BlobSimilarResponse{
|
||||||
Height: height,
|
ID: id,
|
||||||
PreviewUrl: "/data/" + blob.PreviewFilePath,
|
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
|
return
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,11 @@ type BlobResponse struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type BlobSimilarResponse struct {
|
type BlobSimilarResponse struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Width int `json:"width"`
|
Width int `json:"width"`
|
||||||
Height int `json:"height"`
|
Height int `json:"height"`
|
||||||
Similar []PostSimilarityListItem `json:"similar"`
|
PreviewUrl string `json:"previewUrl"`
|
||||||
|
Similar []PostSimilarityListItem `json:"similar"`
|
||||||
}
|
}
|
||||||
type PostPaginationResponse struct {
|
type PostPaginationResponse struct {
|
||||||
CurrentPage int `json:"currentPage"`
|
CurrentPage int `json:"currentPage"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user