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('\\', '/')}

 

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2022-02-25
  • 2022-12-23
  • 2021-12-18
  • 2021-12-18
  • 2022-01-14
  • 2021-07-21
猜你喜欢
  • 2021-08-20
  • 2021-12-18
  • 2021-12-18
  • 2021-12-28
  • 2021-05-08
  • 2022-12-23
相关资源
相似解决方案