File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed
Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ parse_rest
2020 - Installation querying
2121 - push
2222 - Roles/ACLs**
23- - ** PLANNED/TODO ** : Image/File type support
23+ - Image/File type support (done 1/14/17)
2424
2525
2626** for applications with access to the MASTER KEY, see details below.
@@ -269,6 +269,40 @@ collectedItem.save() # we have to save it before it can be referenced
269269gameScore.item = collectedItem
270270~~~~~
271271
272+
273+ File Support
274+ ---------------
275+
276+ You can upload files to parse (assuming your ` parse-server ` instance supports it).
277+ This has been tested with the default GridStore adapter.
278+
279+ Example:
280+
281+ ~~~~~ {python}
282+ from parse_rest.datatypes import Object, File
283+
284+ class GameScore(Object):
285+ pass
286+
287+ # 1. Upload file
288+
289+ with open('/path/to/screenshot.png', 'rb') as fh:
290+ rawdata = fh.read()
291+
292+ screenshotFile = File('arbitraryNameOfFile', rawdata, 'image/png')
293+ screenshotFile.save()
294+
295+ print screenshotFile.url
296+
297+ # 2. Attach file to gamescore object and save
298+ gs = GameScore.Query.get(objectId='xxxxxxx')
299+ gs.screenshot = screenshotFile
300+ gs.save()
301+
302+ print gs.file.url
303+ ~~~~~
304+
305+
272306Batch Operations
273307----------------
274308
You can’t perform that action at this time.
0 commit comments