def _save(self, name, content):
if not hasattr(content, 'seek'):
raise SuspiciousFileOperation('The django-cockatiel backend can only deal with '
'files that support seeking.')
content.seek(0)
sha1 = hashlib.sha1()
while True:
chunk = content.read(1024)
if not chunk:
break
sha1.update(chunk)
content.seek(0)
def put(node):
resp = requests.put(self._get_url(node, name), data=content, headers={
'X-Content-SHA1': sha1.hexdigest()
}, allow_redirects=False)
resp.raise_for_status()
return resp
resp = self._retry(put)
loc = resp.headers['Location']
if loc.startswith('/'):
loc = loc[1:]
return loc
评论列表
文章目录