Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 178731e

Browse files
committed
CstringIO thing for #99
1 parent fba8599 commit 178731e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

documentcloud/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,15 +261,18 @@ def upload(
261261
"""
262262
# Required parameters
263263
if hasattr(pdf, 'read'):
264-
size = os.fstat(pdf.fileno()).st_size
264+
try:
265+
size = os.fstat(pdf.fileno()).st_size
266+
except:
267+
size = None
265268
params = {'file': pdf}
266269
else:
267270
size = os.path.getsize(pdf)
268271
params = {'file': open(pdf, 'rb')}
269272
# Enforce file size limit of the DocumentCloud API
270273
if size >= 399999999:
271274
raise ValueError("The pdf you have submited if over the \
272-
DocumentCloud API's 400MB file size limit. Split it into smaller pieces\
275+
DocumentCloud API's 400MB file size limit. Split it into smaller pieces \
273276
and try again.")
274277
# Optional parameters
275278
if title:

0 commit comments

Comments
 (0)