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:-

https://github.com/dreamfactorysoftware/dsp-core/wiki/File-Storage-Services

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?

Thanks

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

$.ajax({
    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,
    cache:false,
    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

http://jsfiddle.net/specialjyo/a0umb9js/1/

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:
thanks!

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:

https://wiki.dreamfactory.com/DreamFactory/Features/Files
https://wiki.dreamfactory.com/DreamFactory/Tutorials/Uploading_File
https://wiki.dreamfactory.com/DreamFactory/Tutorials/Downloading_File
https://wiki.dreamfactory.com/DreamFactory/Tutorials/Deleting_File
https://wiki.dreamfactory.com/DreamFactory/Tutorials/Adding_a_text_file