Now that the DB design for the item management function is complete, let's create an api. The required api is
What a place, such as. There are quite a few.
This time I made a circle around. You can create a circle and change the icon and circle name.
https://github.com/nagai/freemarket/tree/20140405
When handling the image received by multipart / form-data (key is'circlecut')
Can access
cloud storage
Use Google Cloud Storage Python Client Library to access Cloud Storage on GAE https://developers.google.com/appengine/docs/python/googlecloudstorageclient/?hl=ja
Writing files to GCS
controller/user/api/circle.py
circlecutBlob = self.request.get('circlecut')
circlecutType = self.request.params["circlecut"].type
circlecutHash = hashlib.md5(circlecutBlob).hexdigest()
circlecutpath = Common.createCirclecutPath(circlecutHash)
gcs_file = gcs.open(circlecutpath,
'w',
content_type=circlecutType,
options={},
retry_params=gcs.RetryParams(backoff_factor=1.1))
gcs_file.write(circlecutBlob)
gcs_file.close()
The image that was sent by the POST request multipart / form-data is saved in CloudStorage with the file path of'/ freemarket / circlecut / MD5'. Recent App Engine has CloudStorage for local environment, and if it is the file saved this time, you can check it from the browser in the form of http: // localhost: 8080 / _ah / gcs / freemarket / circlecut / xxxxxx after starting devserver. Masu
Recommended Posts