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.
24 app.directive('fileModel', ['$parse', function ($parse) {
25 console.log("////////fileModel");
28 link: function(scope, element, attrs) {
30 var model = $parse(attrs.fileModel);
31 //alert("uploadFileToUrl directive model :: " + model);
32 var modelSetter = model.assign;
34 element.bind('change', function(){
35 console.log("change");
36 scope.$apply(function(){
38 modelSetter(scope, element[0].files[0]);
46 app.service('fileUpload', ['$http', '$q', function ($http, $q) {
47 console.log("fileUpload");
48 this.uploadFileToUrl = function(file, uploadUrl){
49 console.log("uploadFileToUrl");
50 //alert("uploadFileToUrl file :: " + file + " :: url::" + uploadUrl);
55 var fd = new FormData();
56 fd.append('requestFile', file);
57 $http.post(uploadUrl, fd, {
58 transformRequest: angular.identity,
59 headers: {'Content-Type': undefined}
61 .success(function(data){
62 console.log("success");
66 .error(function(data){
68 def.reject("Upload file not successful");
74 this.uploadFile = function(path,inputFile,uploadURL){
75 console.log("uploadFile");
79 var fd = new FormData();
80 fd.append('requestFile', inputFile);
81 fd.append('path',path)
82 $http.post(uploadURL, fd, {
83 transformRequest: angular.identity,
84 headers: {'Content-Type': undefined}
86 .success(function(data){
87 console.log("success");
91 .error(function(data){
93 def.reject("Upload file not successful");