#File re-upload issues

3 messages · Page 1 of 1 (latest)

vital crater
#

If a file gets re-uploaded using the same file name the postfix changes to '-1' on the first re-upload and back to the original file on second re-upload. I would prefer if the file name would stay the same in this condition.

The second issue was with the rich-text field which was still refering to the old filename and URL. I thought the JSON data would only contain the collection name and the document ID but the full data of the media item is stored in MongoDB. This is dangerous and also wastes some space. In order to support any media file changes we have to query the media item anyway and storing an ObjectId would be sufficient. This would prevent other users running into the same issue.

Ideally the depth query parameter should be taken into account for rich-text data as well.

ornate pawnBOT
sullen grove
#

Hey @vital crater, regarding the first issue, the postfix is appended automatically only if that filename already exists. If you re-upload 'file.jpg' when 'file.jpg' already exists, it will be set to 'file-1.jpg'. If you re-upload a second time, 'file.jpg' is no longer taken, as the filename would be 'file-1.jpg'. You can always rename your files manually if you want to control the numbering.

For the second issue, the data in the rich text field should have updated content if you've saved changes to the upload referenced. If that's not happening for your, there may be an issue with your set up. Besides that, if you want to just return the id or other specific fields, you can use an afterRead hook to modify the data returned.