protected bool _attach_file_command(Guid?applicationId, DocFileInfo fileInfo, ref string responseText, ref byte[] fileContent, bool dontStore = false) { HttpContext context = HttpContext.Current; string filename = context.Request.Headers["X-File-Name"]; filename = HttpUtility.UrlDecode(filename); if (string.IsNullOrEmpty(filename) && context.Request.Files.Count > 0) { filename = context.Request.Files[0].FileName; } if (filename.IndexOf("Encoded__") == 0) { filename = Base64.decode(filename.Substring(("Encoded__").Length)); } if (string.IsNullOrEmpty(filename) && context.Request.Files.Count <= 0) { responseText = "{\"success\":false}"; return(false); } fileInfo.Size = context.Request.InputStream.Length; fileInfo.FileName = ""; fileInfo.Extension = ""; int indexOfLastDot = filename.LastIndexOf('.'); if (indexOfLastDot >= 0 && indexOfLastDot < filename.Length - 1) { fileInfo.Extension = filename.Substring(indexOfLastDot + 1).ToLower(); } fileInfo.FileName = string.IsNullOrEmpty(fileInfo.Extension) ? filename : filename.Substring(0, indexOfLastDot); FolderNames fn = fileInfo.FolderName.HasValue ? fileInfo.FolderName.Value : FolderNames.TemporaryFiles; bool result = filename == null? __ie_response(applicationId, context.Request.Files[0], fileInfo, ref responseText, ref fileContent, dontStore) : __other_browsers_response(applicationId, context.Request.InputStream, fileInfo, ref responseText, ref fileContent, dontStore); if (!result) { return(false); } if (applicationId.HasValue && paramsContainer.CurrentUserID.HasValue && fileInfo.OwnerID.HasValue && fileInfo.OwnerID != Guid.Empty && fileInfo.FileID != null) { result = DocumentsController.add_file(applicationId.Value, fileInfo.OwnerID.Value, fileInfo.OwnerType, fileInfo, paramsContainer.CurrentUserID.Value); if (!result) { fileInfo.move(paramsContainer.ApplicationID, fn, FolderNames.TemporaryFiles); responseText = "{\"success\":false}"; return(false); } } return(true); }