OSDN Git Service

Before trying websocket
[eos/zephyr.git] / client / app / components / uploadFileModal / uploadFileModal.controller.js
index dad7288..2b76acd 100644 (file)
@@ -2,28 +2,28 @@
 
 angular.module('zephyrApp')
 .controller('UploadFileModalController', function($scope, $modalInstance, Restangular) {
-    var baseNoteSaving = Restangular.all('/api/noteCreation')
+    // To send multipart request from angular, we should set below
+    var baseUpload = Restangular.all('/api/upload').withHttpConfig({transformRequest: angular.identity})    
+    $scope.upload = function() {
+        var fd = new FormData()
+        console.log($scope.files)
+        /*
+           angular.forEach($scope.files, function(file) {
 
-    $scope.save = function() {
-        var note = {
-            name: $scope.noteName
-        }
-        note.content = new Array()
-        angular.forEach($scope.commandDirectives, function(command) {
-            if(command.isCompleted) {
-                var obj = {
-                    command  : command.params.command,
-                    inputDir : command.params.inputDir,
-                    outputDir: command.params.outputDir,
-                    optionDatas  : command.params.options
-                }
-                note.content.push(obj)
-            }
-        })
-        baseNoteSaving.post(JSON.stringify(note)).then(function(status) {
-            console.log(status)
-            $modalInstance.close()
-        })
+           fd.append("dir", $scope.path)
+           fd.append("files", file)
+
+           baseUpload.customPOST(fd, undefined, undefined, { 'Content-Type': undefined })
+           .then(function(status) {
+           console.log('File upload', status)
+           $modalInstance.close()
+           })
+           })
+           */
+    }
+
+    $scope.bindFiles = function(files) {
+        $scope.files= files 
     }
 
     $scope.close = function() {