Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bram van den Bogaard 9 posts 104 karma points
    Feb 18, 2022 @ 14:37
    Bram van den Bogaard
    0

    Uploading multiple images from ContentApp

    I'm currently working on a custom ContentApp that needs to send text and (optional) images to an API.

    I've created the API first and everything works fine with Postman. However, when I try and send data from the ContentApp the images are not received in the API.

    I'm trying to use the Upload service in my AngularJs controller to send an array of files which looks like this:

     Upload.upload({
                url: "/umbraco/api/supportmodule/createTicket",
                fields: {
                    //These are additional fields you can send and use as FormData
                    'name': $scope.nameField.value,
                    'email': $scope.emailField.value,
                    'subject': $scope.subjectField.value,
                    'description': completeMessageField,
                    'priority': $scope.priorityField.value,
                },
                file: $scope.filesHolder.value
            })
    

    The HTML seems to work correctly and look like this:

                <umb-control-group label="{{filesHolder.label}}" description="{{filesHolder.description}}">
                <input id="FilePicker" type="file" accept="image/*" ngf-select ngf-model="filesHolder" ngf-change="vm.handleFiles($files, $event)" ngf-multipart="true" multiple />
            </umb-control-group>
    

    I'm using a List<IFormFile> value in the model that is null after sending the post request (this is correctly filled when using Postman)

    Can someone explain to me how to upload multiple files and make sure they are bound to the model correctly ?

    enter image description here enter image description here

  • Alexander Tkacuk 19 posts 120 karma points
    Feb 21, 2022 @ 06:54
    Alexander Tkacuk
    0

    Hi,

    i'm not sure if this is the solution, but have a look at "transformRequest" parameter in angularJS.

    An example of this is at StackOverflow.

Please Sign in or register to post replies

Write your reply to:

Draft