可以把文件放在DataStore的BlobProperty里。但是请注意每个文件不能超过1M.google有限制。 例子: model: class UploadFile(db.Model): data = db.BlobProperty() orig_name = db.StringProperty() ext = db.StringProperty() date = db.DateTimeProperty(auto_now_add=True) 上传: class Upload(BaseRequestHandler): @requires_admin def post(self): filename = self.param('filename') data = self.param('upfile') fileext = self.param('fileext') models.UploadFile(orig_name = filename, ext = fileext, data = data).put() 下载: class Download(BaseRequestHandler): def get(self, file): filename = self.request.path[len('/upload/'):] split = filename.rfind('.') if split == -1: name, ext = filename, '' else: name = filename[:split] ext = filename[split + 1:]
file = models.UploadFile.get(db.Key(name)) if not file: self.main('没有找到这个文件!') return elif file.ext != ext: self.main('没有找到这个文件!') return else: ext = '.' + ext mimetype = 'application/octet-stream' if types_map.has_key(ext): mimetype = types_map[ext] self.response.headers['Content-Type'] = mimetype self.response.headers['Content-Disposition'] = 'inline; filename="' + file.orig_name.encode('utf-8') + '"' self.response.out.write(file.data) 2008/10/14 kns001 <[EMAIL PROTECTED]>: > > App Engine にて、不明点がありますので投稿させて頂きました。 > > 【不明点】 > App Engineを使用した外部ファイルの取込と取出が可能でしょうか? > > 例:Aさんが、App Engineにて作成したAPPを使用して自端末上のファイル > (テキスト、word、excel、pdf等)をAppEngineサーバ(DataStoreAPI等を使用)に取り込む。 > 続いてBさんが、同APPを使用してそのファイルを取り出して自端末にダウンロードし閲覧する。 > > また、例のようなDataStoreAPIでGoogleサーバに取り込まなくても他に可能な > 代替案などがあればご教授いただきたいと思います。 > > どうぞよろしくお願いいたします。 > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to google-appengine@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en -~----------~----~----~----~------~----~------~--~---