/// <summary> /// Uploads the specified file. /// </summary> /// <param name="file">The file.</param> /// <param name="fileName">Name of the file.</param> /// <returns> /// The URI of the file that was uploaded. /// </returns> public Uri Upload(HttpPostedFileBase file, string fileName) { var fullPath = Path.Combine(this.localPath, fileName); var serverPath = VirtualPathUtility.IsAppRelative(fullPath) ? HttpContext.Current.Server.MapPath(fullPath) : fullPath; LocalSiteFileUploader.CreateDirectory(serverPath); file.SaveAs(serverPath); return this.GetUri(fullPath); }
/// <summary> /// Uploads the specified file. /// </summary> /// <param name="stream">The stream.</param> /// <param name="fileName">Name of the file.</param> /// <returns> /// The URI of the file that was uploaded. /// </returns> public Uri Upload(Stream stream, string fileName) { var fullPath = Path.Combine(this.localPath, fileName); var serverPath = VirtualPathUtility.IsAppRelative(fullPath) ? HttpContext.Current.Server.MapPath(fullPath) : fullPath; LocalSiteFileUploader.CreateDirectory(serverPath); using (var file = File.OpenWrite(serverPath)) { stream.CopyTo(file); } return this.GetUri(fullPath); }