Uploaded Files Via POST

Does anyone have any examples of posting files to the local storage? The documentation in the Git Wiki is shall we say, a tad light:-


I’m trying to create an area for users to upload an image to use as a profile picture using the ng-flow extension.

How does the DSP govern permissions for each container/directory/file too?


2 headers required with a file upload, here’s the jquery way ->

    beforeSend: function(request) {
        request.setRequestHeader("X-File-Name", file.name);
        request.setRequestHeader("Content-Type", file.type);
    type :'POST',
    url :{yourdspurl}/rest/files/{container}/{file_path} createFile()
    data: yourfile,
    processData: false

Security is at the container level currently, not down to the folder/file level.

Documentation forthcoming.

1 Like

Hey Antony, Ben here. If you need visibility control of the image at the file level (e.g. user can only see his own image), one option would be to store the image in the db and use record-level permissions to enforce that rule.

Angular Way


Thanks for the help guys, I was planning on tackling this today and @Jason your example is the cherry on top!

Also take a look at Jenny’s blog post linked from the wiki https://github.com/dreamfactorysoftware/dsp-core/wiki/File-Storage-Services

It works!:heart_eyes:

HI Ben!
The link that you posted isn’t working anymore. Would there happen to be another example link similar?

@drexelsharp Sorry about that. This info in the docs should be helpful: