def download(self):
"""
Download the LaTeX source of this paper and save to storage. It will
save the model.
"""
# Delete an existing file if it exists so we don't clutter up storage
# with dupes. This might mean we lose a file the download fails,
# but we can just download it again.
if self.source_file.name:
self.source_file.delete()
res = requests.get(self.get_source_url())
res.raise_for_status()
extension = guess_extension_from_headers(res.headers)
if not extension:
raise DownloadError("Could not determine file extension from "
"headers: Content-Type: {}; "
"Content-Encoding: {}".format(
res.headers.get('content-type'),
res.headers.get('content-encoding')))
content = ContentFile(res.content)
self.source_file.save(self.arxiv_id + extension, content)
评论列表
文章目录