AppEngine:从提取的URL上传到S3时只获得1KB
我正在尝试上传从服务器获取的文件。但是当获取的文件大于1MB时,S3上只保存1KB的小文件。当它小于1MB时,文件将被正确保存。
我搜索并尝试了不同的方法,但没有一个是有效的。这是由用户单击按钮触发的类。
`
class Fetch_by_button(webapp.RequestHandler):
def get(self):
#1. fetch the file
try:
result = urlfetch.fetch('http://someurl.com/music.mp3') # file with 2MB
#result = urlfetch.fetch('http://anotherurl.com/document.pdf') #file with 900KB is working
except DownloadError:
print("URL fetch doesnt work properly")
#2. search datastore UserData-model by userobject to get s3 credentials
usr = users.get_current_user()
query = UserData.gql("WHERE account =:1", usr)
qr = query.get()
#3. establish connection to s3
conn = S3Connection(qr.s3_accesskey, qr.s3_secret_accesskey)
#4. create bucket
ak_lowercase = str.lower(str(qr.s3_accesskey))
individual_bucket_name = ak_lowercase + '_' + usr.nickname()
bucket = conn.create_bucket(individual_bucket_name)
#5. generate key and assign to already created bucket
k = Key(bucket)
#6. name the key by some examplary filename
k.key = 'justsomefilename'
#7. save the correspondent value to the created key
k.set_contents_from_string(result.content)`
我不知道为什么会发生这种情况。我的代码,一些AppEngine限制,任何与boto,...有什么建议?
提前致谢。
没有找到相关结果
已邀请:
1 个回复
脖呐