Search code examples
pythongoogle-app-engineutf-8encodeblobstore

GAE blobstore filename UTF-8 encoding problem


I have some filename encoding problem in GAE blobstore here.

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        upload_files = self.get_uploads('file') 
        blob_info = upload_files[0]

        #Problem right here    
        decoded_filename = blob_info.filename.decode("utf-8")
        #

        File_info = Fileinfo(
            key_name=str(blob_info.key()),
            filename=decoded_filename,
            )
        File_info.put()
        self.redirect("/")

When I run in local, it function normal in SDK console, alt text

but after upload to GAE it store it shows like non-decode string "=?UTF-8?B?54Wn54mH5pel5pyfIDIwMTAtMDgtMDM=?=" or =?Big5?B?v8O59afWt9MgMjAxMC0xMi0wMiA=?=

alt text

I doubt the best solution might be, stop using Chinese character filename ...

All suggestions are very welcome :)


Solution

  • It's an open issue: Blobstore handler breaking data encoding, check here.