[server] Add validation for object_keys

This commit is contained in:
Neeraj Gupta 2024-11-13 12:04:55 +05:30
parent 4b99b1c20c
commit bd53eaec28

View File

@ -64,6 +64,9 @@ func (c *FileController) validateFileCreateOrUpdateReq(userID int64, file ente.F
if !strings.HasPrefix(file.File.ObjectKey, objectPathPrefix) || !strings.HasPrefix(file.Thumbnail.ObjectKey, objectPathPrefix) {
return stacktrace.Propagate(ente.ErrBadRequest, "Incorrect object key reported")
}
if file.File.ObjectKey == file.Thumbnail.ObjectKey {
return stacktrace.Propagate(ente.ErrBadRequest, "file and thumbnail object keys are same")
}
isCreateFileReq := file.ID == 0
// Check for attributes for fileCreation. We don't send key details on update
if isCreateFileReq {