0
Pythonリクエストを使用してスクリプトを実行するとチャンクエンコーディングエラーが発生しました。私はresp.encoding
を行うとPythonリクエストを使用したチャンクエンコーディング - エラー10054の接続が強制的にリモートホストによって閉じられました
私はそれを取り戻すNone
私は現在、私のスクリプト内の任意のSSL証明書の検証を使用していないので、私は同様に安全でない要求の警告を取得します。
for attachment in attachments:
if attachment['type'] == 'Form':
continue
# create insertcursor row
row = cursorPointData.newRow()
pprint(attachments)
for key in attachment:
pprint(key)
pprint(attachment[key])
row.setValue(key, attachment[key])
# Download file
guid = attachment['guid']
resp = requests.get(
'https:...' + guid,
headers={'Authorization': 'Bearer ' + token},
stream=True,
verify=False
)
contentType = resp.headers['Content-Type']
contentLength = int(resp.headers['content-length'])
pprint('contentLength = ' + str(contentLength))
extension = contentType.split('/')[1]
filename = '{0}.{1}'.format(guid, extension)
output_path = os.path.join(attachmentDir, filename)
attachmentPath = os.path.join("filepath", filename)
with open(output_path, 'wb') as f:
for chunk in resp.iter_content(chunk_size=None):
if chunk:
f.write(chunk)
f.flush() #flush the data to file
os.fsync(f.fileno()) #force the file write and free memory
row.setValue('attachmentPath', attachmentPath)
cursorPointData.insertRow(row)
del cursorPointData, row