更新时间:2023-02-10 14:18:25
这个问题对我提出了挑战,所以我在我的带有本地存储的虚拟应用程序上做了一些测试.
This question challenged me, so I did some test on my dummy app with local storage.
我有通常的模型 User
其中 has_one_attached :avatar
I have the usual model User
which has_one_attached :avatar
本地存储文件保存在/storage
文件夹下,子文件夹下随机命名为两个字符的字符串.
On local storage files are saved on /storage
folder, under subfolders named randomly with a string of two characters.
与文件相关的信息存储在两个表中:
Informations related to files are stored in two tables:
为了彻底清理两个表,我在rails控制台
中做了:
ActiveStorage::Attachment.all.each { |attachment| attachment.purge }
该命令删除
ActiveStorage::Attachment.any?#=>假
ActiveStorage::Blob.any?#=>假
/storage
子文件夹下的所有文件;当然,子文件夹仍然是空的.ActiveStorage::Attachment.any? #=> false
ActiveStorage::Blob.any? #=> false
/storage
subfolders; of course, subfolders are still there empty.ActiveStorage 仍然可以正常工作.
The ActiveStorage still works poperly.
我希望远程存储具有相同的行为,并具有正确的权限.
I expect the same behaviour for remote storage, having the right privileges.