Open rhclayto opened 8 years ago
@rhclayto This looks great, thank you. I'd recommend creating a Pull Request
for this, and then your code can be merged in and yourself given credit for the contributions.
I'm new to Github so I'll spend a little time learning about pull requests then do it! Thanks.
Okay, I made a pull request. I hope everything's copacetic. Github's tools seems pretty cool.
Hi,
I needed to use the 'attach files to node resource' targeted action provided by services but didn't find that capability in this module. I got something working & thought I'd share it.
Here's the code for the Angular Drupal module:
Setting Content-Type: undefined, & transformRequest: angular.identity are essential to making the browser send the data with the proper Content-Type: multipart/form-data & correct boundaries.
Since this targeted action (for some obscure reason) requires multipart/form-data Content-Type POSTs rather than a more REST API/Angular friendly JSON, it requires some fiddling. In my Angular controller I created a FormData() object that gets passed in above as the parameter 'data'. To wit:
According to comments in Services code: 'The name="files[anything]" format is required to use file_save_upload().'
In my example above, $scope.loadedImage is the ng-model set on my file element. According to this article, ng-model doesn’t work on inputs with type=“file”, so I used the custom directive described there to make it work:
&
Hope this helps, & feel free to include it in Angular Drupal! :camel: