我試圖修改用戶表單提交的一些二進制數據,並將其寫入Google Cloud Storage。我試圖按照Google document's example,但在書寫時我的錯誤,如:如何使用GAE的Python API將原始字節寫入Google雲存儲
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 34: ordinal not in range.
我的代碼很簡單,如下
gcs_file = gcs.open(filename,'w',content_type='audio/mp3')
gcs_file.write(buf)
gcs_file.close()
我試圖打開與「WB」模式文件,但有一個「無效模式wb「。錯誤。
我在GCS's maillist上發現了一個類似的問題,這個問題在Java上。 GCS開發團隊的建議是使用writeChannel.write()而不是PrintWriter。任何人都可以建議如何使它在Python中工作嗎?
哪一行產生錯誤? 'gcs.open'或'.write'? – jterrace
.write()函數 – user2686101
你可以發佈完整的堆棧跟蹤嗎? – jterrace