Google app engine正在使用python下载时重命名我的文件

Google app engine正在使用python下载时重命名我的文件,python,google-app-engine,google-cloud-platform,Python,Google App Engine,Google Cloud Platform,我已经编写了一个下载处理程序,它运行良好。但问题是它正在下载名为“download”的文件,下一次它会变成“download(1)”等等。这样地: 我想下载它的实际名称。 这是我的下载处理程序代码: from google.appengine.ext.webapp import blobstore_handlers import functions class DownloadHandler(blobstore_handlers.BlobstoreDownloadHandler): d

我已经编写了一个下载处理程序,它运行良好。但问题是它正在下载名为“download”的文件,下一次它会变成“download(1)”等等。这样地: 我想下载它的实际名称。 这是我的下载处理程序代码:

from google.appengine.ext.webapp import blobstore_handlers
import functions

class DownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
    def get(self):
        filename = self.request.get('file_name')
        file_object = functions.getFileList(filename)
        self.send_blob(file_object.blob)
这是函数getFileList()的代码:

此功能涉及的流程是:

-getCurrentUser():返回登录用户的当前用户id

-getDirectoryList():返回一个目录对象,其中包含一个目录列表

-getFilePath():这将返回文件路径,即userId+directoryPath+filename

例如:185804764220139124118/新文件2019-03-07 03.23.46_1.jpg

这是从HTML文件对main.py的调用:

<td class="table_data icon_row">
       <a href="/download?file_name={{ file }}" class="table_link"><span class="material-icons button">file_download</span></a>
</td>
上面给出了下载处理程序的代码

如何下载带有实际名称的文件


注意:数据存储上的文件名是实际的,但仅在下载时存在一些问题。

True
使用blob的文件名时,您可以使用
save\u as
参数来更改行为

self.send\u blob(文件\u object.blob,另存为=True)

有关更多详细信息,请参阅。

此代码对我有效

class DownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self):
    filename = self.request.get('file_name')
    key1 = functions.getFileList(filename)
    blob_info = blobstore.BlobInfo.get(blobstore.BlobKey(str(key1.blob)))
    self.send_blob(blob_info,save_as=True)

感谢@Dustin Ingram

嘿!我已经试过了,但是我遇到了一个错误。ValueError:blob\u key\u或\u info应为BlobInfo值。我也可以给你完整的错误追踪。但是评论中的角色限制不允许我这么做。
app = webapp2.WSGIApplication(
[
    ('/', MainPage),
    ('/upload', UploadHandler),
    ('/download', DownloadHandler)
], debug=True)
class DownloadHandler(blobstore_handlers.BlobstoreDownloadHandler):
def get(self):
    filename = self.request.get('file_name')
    key1 = functions.getFileList(filename)
    blob_info = blobstore.BlobInfo.get(blobstore.BlobKey(str(key1.blob)))
    self.send_blob(blob_info,save_as=True)