Search Posts

Category: ng-file-upload

Required request part is not present – Spring

I am trying to pass the attached file information to the spring controller from agularjs controller. I am facing issues while passing the information from angularjs to spring controller, it is throwing the error on the browser console and not calling the spring controller. Error message: error : “Required request part ‘ad’ is not present” status : 500 Below is the sample code i have used in my application to send the attached files and […]

Angular Upload service change the name field

I am using ng-fileUpload service. I want to change the name field in the request payload to name of the file. Is it possible to change the name field in the request using the same service? Please let me know. The angular function and the request payload is as below. function uploadFile(file) { return Upload.upload({ url: `…/api/myPostEndPoint`, data: { file } }) .then(() => { //success }) .catch(error => { //error }); } The request […]

I need to upload a file to server using angularJS, NodeJS and ExpresJS

I tried following this link but got error Node version is 4.4.7 modulerr error in ngFileUpload In controller I have var CIController = angular.module(‘CIController’, [‘ngMaterial’, ‘ngAnimate’, ‘ngAria’, ‘ngMessages’, ‘Alertify’, ‘ngFileUpload’]) .controller(‘childController’, [‘$scope’, ‘$location’, ‘$q’, ‘$timeout’, ‘$log’, ‘CIFactory’, ‘ClientConfig’, ‘Alertify’, ‘Upload’, ‘$window’, function($scope, $location, $q, $timeout, $log, CIFactory, ClientConfig, Alertify, Upload, $window) { // … } Source: AngularJS

How to map a list of objects to a List<Object> in Spring boot controller

I want to pass list of objects from front end (AngularJs) to a Spring Boot controller via POST method. I have tried following code. Angular Upload.upload({ url: ‘/customerRegister’, method: ‘POST’, headers: {‘Content-Type’: undefined}, data: { file: $scope.file, ‘objectList’: $scope.customerDetails.objectList } }); Spring Controller @RequestMapping(value = “/customerRegister”, method = RequestMethod.POST) public ResponseEntity<?> customerDetailsRegister(MultipartRequest request, @ModelAttribute ObjectList objectList, BindingResult bindingResult, Model model) throws commonException { // controller body } Bean Class public class ObjectList { private List<CustomerObject> […]

how to display image with blob image url?

I have blob url for image and want to display it. One method I tried is by using createObjectURL(). $scope.preview = function(path) { //path is ‘data:image/jpeg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAA….’ var file = new Blob([ path ], { type : ‘image/jpeg’ }); var fileURL = URL.createObjectURL(file); //fileURL is blob:http://localhost:8080/a8610a32-521f-407c-8f…. console.log(‘fileurl: ‘, fileURL); $(‘img.image-preview’).attr(‘ng-src’, fileURL); } The blobl url I am getting is by ng-file-upload 7.2.2. Source: AngularJS

ng-file-upload directive upload to server works via Gallery but not Camera although both use same function?

I am using the Angular directive ng-file-upload to upload images from my iOS device to a remote server. // html <button ng-if=”deviceInfo.platform == ‘iOS'” class=”btn btn-camera” type=”file” ngf-select=”onFileSelect($files)” multiple accept=”{{acceptStr}}” ngf-fix-orientation=”true”><span class=”btn-camera-text”>Browse gallery</span></button> // javascript $scope.uploadImage = function(files, fileIndex, imageIndex) { if (!angular.isDefined(fileIndex)) { fileIndex = 0; imageIndex = 0; } var file = files[fileIndex]; var image = $[imageIndex]; var uploadTarget = “/api/upload”; Upload.upload({ url : uploadTarget, data : { __token : $localStorage.token.value, file : […]

ng-file-upload each values in data are converting to arrays in server side

trying to upload service, here’s my upload function looks like $scope.upload = function(){ Upload.upload({ url: /upload_url/, method:’POST’, data: {file: $scope.file, ‘message’: “test”} }).then(function (response) { }, function (response) { if (response.status > 0) $scope.errorMsg = response.status + ‘: ‘ +; }, function (evt) { $scope.progress = parseInt(100.0 * evt.loaded /; }); } and file input element looks like <input type=”file” ngf-select=”” ng-model=”file” name=”file” ngf-accept=”‘image/*'” data-classbutton=”btn btn-default”data-classinput=”form-control inline” class=”filestyle form-control”> but in serverside I […]