refabrique : une librairie serveur
This commit is contained in:
@ -52,18 +52,18 @@ namespace Yavsc.ApiControllers
|
||||
return Ok(files);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Post(string subdir="", string names = null)
|
||||
[HttpPost("{subdir}")]
|
||||
public IActionResult Post(string subdir="")
|
||||
{
|
||||
string root = null;
|
||||
string [] destinationFileNames = names?.Split('/');
|
||||
string destDir = null;
|
||||
List<FileRecievedInfo> received = new List<FileRecievedInfo>();
|
||||
InvalidPathException pathex = null;
|
||||
try {
|
||||
root = User.InitPostToFileSystem(subdir);
|
||||
destDir = User.InitPostToFileSystem(subdir);
|
||||
} catch (InvalidPathException ex) {
|
||||
pathex = ex;
|
||||
}
|
||||
logger.LogInformation($"Recieving files, saved in '{destDir}' (specified ad '{subdir}').");
|
||||
if (pathex!=null)
|
||||
return new BadRequestObjectResult(pathex);
|
||||
var uid = User.GetUserId();
|
||||
@ -72,11 +72,11 @@ namespace Yavsc.ApiControllers
|
||||
);
|
||||
int i=0;
|
||||
logger.LogInformation($"Recieving {Request.Form.Files.Count} files.");
|
||||
|
||||
foreach (var f in Request.Form.Files)
|
||||
{
|
||||
var destFileName = destinationFileNames?.Length >i ? destinationFileNames[i] : null;
|
||||
|
||||
var item = user.ReceiveUserFile(root, f, destFileName);
|
||||
|
||||
var item = user.ReceiveUserFile(destDir, f);
|
||||
dbContext.SaveChanges(User.GetUserId());
|
||||
received.Add(item);
|
||||
logger.LogInformation($"Recieved '{item.FileName}'.");
|
||||
|
@ -46,7 +46,7 @@ namespace Yavsc.Helpers
|
||||
}
|
||||
var di = new DirectoryInfo(root);
|
||||
if (!di.Exists) di.Create();
|
||||
return root;
|
||||
return di.FullName;
|
||||
}
|
||||
|
||||
public static void DeleteUserFile(this ApplicationUser user, string fileName)
|
||||
@ -66,6 +66,7 @@ namespace Yavsc.Helpers
|
||||
ContentDisposition contentDisposition = new ContentDisposition(f.ContentDisposition);
|
||||
item.FileName = Yavsc.Abstract.FileSystem.FileSystemHelpers.FilterFileName (destFileName ?? contentDisposition.FileName);
|
||||
item.MimeType = contentDisposition.DispositionType;
|
||||
item.DestDir = root;
|
||||
var fi = new FileInfo(Path.Combine(root, item.FileName));
|
||||
if (fi.Exists)
|
||||
{
|
||||
|
@ -39,6 +39,8 @@ namespace Yavsc.Helpers
|
||||
using Models;
|
||||
using Models.Calendar;
|
||||
using Services;
|
||||
using Server.Helpers;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Google helpers.
|
||||
|
@ -31,16 +31,17 @@ using Google.Apis.Calendar.v3.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Google.Apis.Services;
|
||||
using System.Threading;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Google.Apis.Auth.OAuth2.Responses;
|
||||
using Google.Apis.Util;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
using System.Threading;
|
||||
using Google.Apis.Auth.OAuth2.Flows;
|
||||
using Google.Apis.Auth.OAuth2.Responses;
|
||||
using Google.Apis.Util;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Calendar;
|
||||
using Yavsc.Server.Helpers;
|
||||
using Yavsc.ViewModels.Calendar;
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,8 +19,8 @@
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.Helpers;
|
||||
using Yavsc.Models.Google;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
namespace Yavsc.GoogleApis
|
||||
{
|
||||
|
@ -5,7 +5,6 @@ using MimeKit;
|
||||
using MailKit.Security;
|
||||
using System;
|
||||
using Yavsc.Models.Messaging;
|
||||
using Yavsc.Helpers;
|
||||
using Microsoft.AspNet.Identity;
|
||||
using Yavsc.Models;
|
||||
using Yavsc.Models.Google.Messaging;
|
||||
@ -15,6 +14,7 @@ using Yavsc.Interfaces.Workflow;
|
||||
using System.Linq;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Yavsc.Server.Helpers;
|
||||
|
||||
namespace Yavsc.Services
|
||||
{
|
||||
|
@ -122,6 +122,11 @@
|
||||
"Microsoft.AspNet.OWin": "1.0.0-rc1-final",
|
||||
"System.Json": "4.0.20126.16343",
|
||||
"Yavsc.Abstract": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
},
|
||||
"Yavsc.Server": {
|
||||
"target": "project",
|
||||
"type": "build"
|
||||
},
|
||||
"Microsoft.AspNet.Http.Extensions": "1.0.0-rc1-final",
|
||||
@ -163,4 +168,4 @@
|
||||
"prepublish": "gulp min"
|
||||
},
|
||||
"embed": "Views/**/*.cshtml"
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user