예제 #1
0
        public object Post(WriteFile request)
        {
            var response = new WriteFileResponse()
            {
                FileName = request.FileName
            };

            string userFolder = Path.Combine("ForUser", this.Database.CurrentUser.Uri.ToString());

            string fullUserFolder = Path.Combine(this.ServiceDefaults.UploadBasePath, userFolder);
            string fileName       = $"{Guid.NewGuid()}.docx";

            if (!Directory.Exists(fullUserFolder))
            {
                Directory.CreateDirectory(fullUserFolder);
            }

            if (string.IsNullOrWhiteSpace(response.FileName))
            {
                response.FileName = Path.Combine(userFolder, fileName);
            }

            using (var stream = new FileStream(Path.Combine(fullUserFolder, fileName), FileMode.Append))
            {
                stream.Write(request.Data, 0, request.Data.Length);
            }

            return(response);
        }
예제 #2
0
        public object Post(WriteFile request)
        {
            var response = new WriteFileResponse()
            {
                FileName = request.FileName
            };

            if (string.IsNullOrWhiteSpace(response.FileName))
            {
                response.FileName = Path.Combine(TrimApplication.WebServerWorkPath, "Uploads", $"{Guid.NewGuid()}.docx");
            }

            using (var stream = new FileStream(response.FileName, FileMode.Append))
            {
                stream.Write(request.Data, 0, request.Data.Length);
            }

            return(response);
        }