Skip to content

Commit c07dc0d

Browse files
add file uploading example to readme
1 parent 26f6808 commit c07dc0d

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.mkd

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff 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
269269
gameScore.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+
272306
Batch Operations
273307
----------------
274308

0 commit comments

Comments
 (0)