memos
memos copied to clipboard
chore: append timestamp to resource filename when uploading to prevent conflict
If we upload two assets with the same name, the later upload will silently overwrite the files uploaded previously.
This PR does not fix this issue but uses a way to decrease the impact by appending the timestamp to the filename.
Uffizzi Ephemeral Environment deployment-18989
:cloud: https://app.uffizzi.com/github.com/usememos/memos/pull/1358
:page_facing_up: View Application Logs etc.
What is Uffizzi? Learn more!
FYI, we already support file path template in https://github.com/usememos/memos/pull/1285
But the filename template cannot solve the situation that I upload two images with same filename in one same day.
This happens more frequently when use the "paste to upload" feature which always set the image's filename to "image.png".
One possible solution with template feature is to add a new placeholder symbol like "{random}". But I think cannot upload files with same name should be treated as bug so should not require user to do some additional settings to avoid it.
I think the original filename should be retained by default.
I think the original filename should be retained by default.
很期待这个功能,都找到commits里来了,说下我的观点吧:
一、区别和现状
把时间信息放在path中和放在filename中,在日常使用没有区别,但在备份云存储图片时,path下载到本地就是一堆的文件夹,为了严格保证图片不被覆盖,就意味着一个文件夹(多层级更麻烦)一个图片,非常不方便。
chrome插件bber支持文件名追加时间戳,涉及到图片的memos,我暂时都改用chrome插件发布,暂时也算不影响使用。
但始终希望官方主程序中能支持这个能力。
二、用法建议
现在的Path配置中有{filename}和{filetype}两个模板变量,所以我以为是配置完整的Path+file,便设置为{year}{month}{day}-{hour}{minute}{second}-{filename}.{filetype},没想到是直接生成了一个20230315-112312-image.png/的目录,然后又接{filename}.{filetype}。
觉得没有必要,都已经把{filename}和{filetype}做成模板变量了,就让用户自己定义完整的path+file路径好了。
想保留文件名不变的,用路径区分可以{year}{month}{day}-{hour}{minute}{second}/{filename}.{filetype}
不用路径,想以文件名区分的可以image-{year}{month}{day}-{hour}{minute}{second}.{filetype}
It's configurable with the local storage path with the value: assets/{timestamp}_{filename}.