from django_oss_storage.backends import OssMediaStorage def upload_oss_file(PostFile, FilePath): try: oss_obj = OssMediaStorage() # 返回图片路径 (oss目录下的文件路径, 图片文件) img_path = oss_obj._save(FilePath, PostFile) except Exception as e: return {'error': "写入文件错误:%s" % e} return {'path': img_path.replace('\\', '/')}