Django 图片附件 FileNotFoundError

Django image attachment FileNotFoundError

我想生成用户上传到我的 Django 站点的附件的缩略图,但由于某种原因我收到以下错误:

FileNotFoundError: [Errno 2] No such file or directory: '/media/tenant-2cadb939-306a-43f2-aa53-eb086a4f74b9/AssignedCampaign/2021-2/53676e7d-c95d-4348-a_581e4TM.png'

尽管文件确实存在。

这是我正在使用的代码:

if a.attachment:
       # get path of attachment without the attachment name
       cache_path = a.full_path.replace('/'+a.full_path.split('/')[-1], '') + '/preview_cache'
       
       log.info('>>>>>>>>>> %s', cache_path)
       
       preview_manager = PreviewManager(cache_path, create_folder=True)
       preview = preview_manager.get_jpeg_preview(a.full_path, width=100, height=200)

我要做的就是给出文件的绝对路径