2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END============================================
20 * ===================================================================
23 app.directive('fileModel', [ '$parse', function($parse) {
24 console.log("////////fileModel");
27 link : function(scope, element, attrs) {
29 var model = $parse(attrs.fileModel);
30 // alert("uploadFileToUrl directive model :: " + model);
31 var modelSetter = model.assign;
32 element.bind('change', function() {
33 console.log("change");
34 scope.$apply(function() {
36 modelSetter(scope, element[0].files[0]);
42 app.service('fileUpload', [ '$http', '$q', function($http, $q) {
43 console.log("fileUpload");
44 this.uploadFileToUrl = function(file, uploadUrl) {
45 console.log("uploadFileToUrl");
48 var fd = new FormData();
49 fd.append('requestFile', file);
50 $http.post(uploadUrl, fd, {
51 transformRequest : angular.identity,
53 'Content-Type' : undefined
55 }).success(function(data) {
56 console.log("success");
59 }).error(function(data) {
61 def.reject("Upload file not successful");
65 this.uploadFile = function(path, inputFile, uploadURL) {
66 console.log("uploadFile");
69 var fd = new FormData();
70 fd.append('requestFile', inputFile);
71 fd.append('path', path)
72 $http.post(uploadURL, fd, {
73 transformRequest : angular.identity,
75 'Content-Type' : undefined
77 }).success(function(data) {
78 console.log("success");
81 }).error(function(data) {
83 def.reject("Upload file not successful");