Exemple #1
0
 public UploadedFile UploadUserFile(string userId, HttpPostedFileBase file)
 {
     string extension = ".unknown";
     UploadedFile uploadedFile = new UploadedFile { FileId = Guid.NewGuid(), Uplaoded = DateTime.UtcNow };
     if (string.IsNullOrWhiteSpace(file.FileName) == false)
     {
         uploadedFile.Name = file.FileName;
         string[] fnParts = file.FileName.Split('.');
         extension = fnParts[fnParts.Length - 1];
     }
     string caUrl = _servicesManager.FileStorage.UploadContentFile(
                            string.Format("cf_{0}", Guid.NewGuid().ToString()),
                            extension, file.InputStream);
     uploadedFile.Url = caUrl;
     uploadedFile.UserId = userId;
     Repository.Add<UploadedFile>(uploadedFile);
     Repository.Save();
     return uploadedFile;
 }
 public FileUploadResponse(UploadedFile response)
 {
     FileId = response.FileId;
     FileName = response.Name;
     FileUrl = response.Url;
     UploadDate = response.Uplaoded;
     ResponseCode = 200;
     Message = "File uploaded successfully.";
 }