2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 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 * ===================================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
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;
33 element.bind('change', function(){
34 console.log("change");
35 scope.$apply(function(){
37 modelSetter(scope, element[0].files[0]);
45 app.service('fileUpload', ['$http', '$q', function ($http, $q) {
46 console.log("fileUpload");
47 this.uploadFileToUrl = function(file, uploadUrl){
48 console.log("uploadFileToUrl");
49 //alert("uploadFileToUrl file :: " + file + " :: url::" + uploadUrl);
54 var fd = new FormData();
55 fd.append('requestFile', file);
56 $http.post(uploadUrl, fd, {
57 transformRequest: angular.identity,
58 headers: {'Content-Type': undefined}
60 .success(function(data){
61 console.log("success");
65 .error(function(data){
67 def.reject("Upload file not successful");
73 this.uploadFile = function(path,inputFile,uploadURL){
74 console.log("uploadFile");
78 var fd = new FormData();
79 fd.append('requestFile', inputFile);
80 fd.append('path',path)
81 $http.post(uploadURL, fd, {
82 transformRequest: angular.identity,
83 headers: {'Content-Type': undefined}
85 .success(function(data){
86 console.log("success");
90 .error(function(data){
92 def.reject("Upload file not successful");