Skip to content

Commit

Permalink
Update docs about file field serialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasgraf committed May 27, 2016
1 parent 1d49315 commit aaeeec0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions docs/source/serialization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,28 @@ File Fields
Download (serialization)
^^^^^^^^^^^^^^^^^^^^^^^^

For download, the file field will simply be serialized to a string that contains the download URL for the file.
For download, the file field will be serialized to a mapping that contains the
file's most basic metadata, and a hyperlink that the client can follow to
download the file:

.. code:: json
{
"...": "",
"@type": "File",
"title": "My file",
"file": "http://localhost:55001/plone/file/@@download/file"
"file": {
"content-type": "application/pdf",
"download": "http://localhost:55001/plone/file/@@download/file",
"filename": "file.pdf",
"size": 74429
}
}
That URL points to the regular Plone download view.

This means that when accessing that URL, your request won't be handled by the API but a regular Plone browser view.
Therefore you must **not** send the ``Accept: application/json`` header in this case.
That URL in the ``download`` property points to the regular Plone download
view. The client can send a ``GET`` request to that URL with an ``Accept``
header containing the MIME type indicated in the ``content-type`` property,
and will get a response containing the file.

Upload (deserialization)
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit aaeeec0

Please sign in to comment.