POST file with metadata

Hi,

Your API docs seem to indicate that I can attach metadata to files that I upload to DSP. I just cannot figure out how to do that. In POST /files/{file_path} it says the schema for the body is:

{
  "name": "string",
  "path": "string",
  "content_type": "string",
  "metadata": [
    "string"
  ]
}

But where does the file content go in this case? On the other hand, I can post the file contents directly, but how do I attach metadata then?

As an example often explains things best, could you give me a plain but complete HTTP request (as opposed to a PHP/JavaScript/whatever API call) that would do the following:

  • uploads file foo.txt
  • with content type text/plain
  • and content “Foo Bar Baz”
  • as well as metadata item “bar=baz”

Thanks.

Hello, You can upload files, with the content in base64 encode. Here is an example with an S3 to upload a File:

POST /api/v2/url HTTP/1.1
Host: domainName
X-DreamFactory-Api-Key: Your DreamFactoryApiKey
Content-Type: application/json

{
“resource”: [{
“name”: “FileName.txt”,
“type”: “file”,
“is_base64”: true,
“content”: “file content with base64 encode goes here”
}
]
}

Thanks, that’s another nice way of posting a file. But what about the metadata? The API talks about such a field, it being an array of strings. Yet, it does not appear to actually be stored. Does it require a specific backend (you are talking about S3 in your answer, I am using local file storage)? Is it a leftover from the past? A hint to the future?