★ (スター) 文字をアプリ エンジン データストアに保存したいのですが、エンコード/デコードの問題があります。
- 残念ながら、開発サーバーでは機能しますが、本番環境では機能しません。
- 以前のアプリで
quopri.decodestring
私の問題を解決しました
まず、AngularJS のフォームを ajax します (無関係である必要があります)。
$http({
method: 'POST',
url: the_upload_url,
transformRequest: formDataObject,
data: event,
headers: {'Content-Type': false}
})
私はwebapp2.RequestHandler
&を持っていますblobstore_handlers.BlobstoreUploadHandler
:
class EditEventHandler(ApiHandler, blobstore_handlers.BlobstoreUploadHandler):
def post(self):
...
print self.request.get('message', 'none')
print len(self.request.get('message', 'none'))
message = unicode(quopri.decodestring(self.request.get('message', 'none')), 'iso_8859-2')
print message
print len(message)
...
#save message to datastore in ndb.TextProperty & send response
App Engine ダッシュボードからのログ出力は次のとおりです。
2013-11-01 10:23:52.506 /admin/event/edit 200 168ms 0kb Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
0.1.0.30 - - [31/Oct/2013:14:23:52 -0700] "POST /admin/event/edit HTTP/1.1" 200 159 "http://www.thebedford.co.nz/dashboard.html" "Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36" "www.thebedford.co.nz" ms=168 cpu_ms=53 cpm_usd=0.000018 app_engine_release=1.8.6 instance=00c61b117c6716cf4503e5f8bfe28fc9e9acd94a
E 2013-11-01 10:23:52.504
4piF
E 2013-11-01 10:23:52.504
4
E 2013-11-01 10:23:52.504
4piF
E 2013-11-01 10:23:52.504
4
ご覧のとおり、星は に変換され4piF
ます。どこが間違っていますか?
以下は、役に立つ場合の POST リクエストです。
Request URL:http://www.thebedford.co.nz/_ah/upload/AMmfu6bKvvqvW6BaQGoGAHTPxBRJe6RafpzaET4pbBxXy-B9TELRochhlRBsZfNGd90xNROxF-dDE4iupO1pmcvey6wUYt46irOFBYyjmmAB_UlVWV8zJ0Lx192jMuSlESRA7dhrbD0k/ALBNUaYAAAAAUnLMvozhzPJMoRmK7kL76D3OWtuJ-dDb/
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/plain, */*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Cache-Control:no-cache
Connection:keep-alive
Content-Length:2867
Content-Type:multipart/form-data; boundary=----WebKitFormBoundaryBBenbmUrxmLeoIgJ
Host:www.thebedford.co.nz
Origin:http://www.thebedford.co.nz
Pragma:no-cache
Referer:http://www.thebedford.co.nz/dashboard.html
User-Agent:Mozilla/5.0 (Windows NT 6.2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36
Request Payload
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="img_slider"
http://lh6.ggpht.com/qC8JR3gNgi9hvuEzkBirWc0AiBMfwhZRz6PMNsZsHefo2JtR-X4vzOvJ-NvwWtWJ4EMquujsTyvh9TgPECqslFA
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="on_homepage"
true
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="event_ticket_link"
http://www.dashtickets.co.nz/event/c2g98fn74
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="date_minute"
0
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="message"
★
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="on_slider"
true
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="img"
http://lh4.ggpht.com/ivvwATwxPL6w8MFb1ox1TABE7M0MIAk-qY4ak69DUn8GrDCEYvDsGFGWxBYPgTNSsUiop5jKYz24gMtmRR6X9vU
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="formatted_date"
Sat 02 Nov 2013
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="date_day"
2
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="date_hour"
22
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="description"
4piF4piF4piF4piF
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="event_name"
Aotearoa Bass ALLSTARZ + NZ Tour +
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="date_year"
2013
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="start_time"
10:00 PM
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="venuemap"
map1
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="key"
ag1zfmJlZGZvcmQtYXBwchcLEgpFdmVudE1vZGVsGICAgICA4pQKDA
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="phone"
4piF
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="date_month"
11
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="notes"
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="venue"
126 Madras Street, CPSA Building Christchurch, New Zealand 8011
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="end_time"
Ti9B4piF
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="on_eventguide"
true
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="event_image"
undefined
------WebKitFormBoundaryBBenbmUrxmLeoIgJ
Content-Disposition: form-data; name="event_slider_image"
undefined
------WebKitFormBoundaryBBenbmUrxmLeoIgJ--
Response Headersview source
Alternate-Protocol:80:quic,80:quic
Cache-Control:no-cache, must-revalidate
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:74
Content-Type:text/html; charset=utf-8
Date:Thu, 31 Oct 2013 21:23:52 GMT
Expires:Fri, 01 Jan 1990 00:00:00 GMT
Pragma:no-cache
Server:HTTP Upload Server Built on Oct 23 2013 16:50:37 (1382572237)
Vary:Accept-Encoding
X-AppEngine-Estimated-CPM-US-Dollars:$0.000018
X-AppEngine-Resource-Usage:ms=168 cpu_ms=64