我的iOS應用與Google應用引擎後端進行交互。我可以選擇讓用戶報告問題。當用戶輸入描述問題的文本並按提交按鈕時,我想開始使用CocoaLumberjack在問題描述中加上應用程序中收集的日誌的後臺上傳。將文件從iOS應用發送到在Google應用引擎上運行的服務器
我目前的方法(幾乎工作)如下。 iOS發送一個multipart/form-data POST請求,其中包含一個帶有錯誤描述和日誌文件內容的字符串(NSData
),每個部分由邊界隔開。 GAE服務器能夠成功解碼每個部分,並且當我使用logging.info()
打印出來時,我能夠看到文件內容。但是,當我嘗試將文件存儲到GCS時,出現錯誤。下面是用於存儲到GCS和錯誤的代碼。
我有一個存儲桶已配置,這有class = Durable Reduced Availability。
有人點我,我做錯了什麼(我懷疑這是一些關於我如何設立在GCS容器的授權名單)?
另外,如果有人有一個更簡單的方法來解決這個問題,我都耳聞。
代碼用於存儲到GCS是:在GAE看出
logging.info('Creating file %s\n' % (filename))
write_retry_params = gcs.RetryParams(initial_delay=0.2,
max_delay=5.0,
backoff_factor=1.2,
max_retry_period=15)
gcs_file = gcs.open(filename,
'w',
content_type='text/plain',
retry_params=write_retry_params)
gcs_file.write(filename=getattr(request, 'fileAttached'))
gcs_file.close()
錯誤:
ForbiddenError: Expect status [201] from Google Storage. But got status 403. Path: '/var/mobile/Containers/Data/Application/4FB6C1D7-9504-4215-BC25-FC490298EEF6/Library/Caches/Logs/com.apm.smartiothome.chatime%202016-01-20%2008-01.log'. Request headers: {'x-goog-resumable': 'start', 'x-goog-api-version': '2', 'content-type': 'text/plain', 'accept-encoding': 'gzip, *'}. Response headers: {'content-type': 'application/xml; charset=UTF-8', 'content-length': '195', 'vary': 'Origin', 'x-guploader-uploadid': 'AEnB2Uo1b-z2VGlHOnurusG2F9bgKcBVwmYWZrQFG4d4NBrHA_tk9wTPoa4kB1Aici7XP7Z6fNtuSJlGDokUmxtCFAl8aMnXGA'}. Body: "
AccessDenied
Access denied.Caller does not have storage.objects.create access to bucket var.". Extra info: None.