从gunicorn + gevent worker,通过django-storages将(多部分)上传到S3,如何确保在计算文件/部件内容的散列期间,事件循环不被阻止?
查看source for django-storages,似乎没有任何传递md5(/另一个哈希)的空间,并且在source for botocore中似乎没有在计算哈希值时产生事件循环的范围。
现在有一个PR for django-storages that calculates the MD5 hash as data received by the application。
总之,这会改变S3Boto3StorageFile
以及init和new part
self._file_md5 = hashlib.md5()
然后收到content_bytes
self._file_md5.update(content_bytes)
然后当上传每个部分时,ContentMD5
参数被传递给部件上传功能
ContentMD5=base64.b64encode(self._file_md5.digest()).decode('utf-8')