我的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.