使用lz4在django rest框架中发送有效负载时压缩和解压缩图像

时间:2018-05-03 07:30:23

标签: python django python-3.x django-rest-framework lz4

我在下面有以下型号。我想压缩上传的文档,然后在POST请求完成后提供解压缩文件的链接。如何在基于类的视图中使用lz4来压缩或解压缩包含图像的有效负载?

models.py

class EmployeeDocument(models.Model):
    """
    Model, Which holds Employee documents uploaded.

    """
    employee = models.ForeignKey(
        Employee, related_name="employee_docs", null=True, blank=True)
    document = models.FileField(
        upload_to='Images/', default='Images/None/No-img.jpg')
    details = models.TextField()

    def __str__(self):
        return 'DOC - %s' % (self.employee.user.username)

0 个答案:

没有答案