Hi,
we are using version 2.19 of the product. We have noticed that for some files types when we preview them, most notably with PDFs, that the a file is also created in the windows temp folder as well as the specified RootStoragePath location which something completely different. Is this expected? Fixed in a later version? Is there a property to stop in happening?
The code we are using is:-
DocURL = DocURL.Replace(""", string.Empty);
RootStoragePath = RootStoragePath.Replace(""", string.Empty);
LicensePath = LicensePath.Replace(""", string.Empty);
Height = Height.Replace(""", string.Empty);
Width = Width.Replace(""", string.Empty);
OrgName = OrgName.Replace(""", string.Empty);
Groupdocs.Web.UI.Viewer.SetRootStoragePath(ConfigurationManager.AppSettings["RootStoragePath"].ToString());
Groupdocs.Web.UI.Viewer.SetLicensePath(ConfigurationManager.AppSettings["LicensePath"].ToString());
//Create a stream for the file
System.Net.HttpWebResponse fileResp = null;
System.Net.HttpWebRequest fileReq = null;
NetworkCredential nc = null;
CredentialCache cache = null;
var username = ConfigurationManager.AppSettings["SharePointUserName"].ToString();
var password = ConfigurationManager.AppSettings["SharePointPassword"].ToString();
var domain = ConfigurationManager.AppSettings["SharePointDomain"].ToString();
var configUsername = ConfigurationManager.AppSettings["SharePointUserName"].ToString();
var configPassword = ConfigurationManager.AppSettings["SharePointPassword"].ToString();
var configDomain = ConfigurationManager.AppSettings["SharePointDomain"].ToString();
//Get Credentials from App Settings
if (!string.IsNullOrEmpty(OrgName))
{
PeppermintNotificationService.SharepointNotificationServiceClient snc = new PeppermintNotificationService.SharepointNotificationServiceClient();
var spCredentials = snc.GetSharePointCredentials(new LogonInfo() { AccessKey = new Guid("{E4E01277-D41E-4F0E-9699-8F9E1619AD27}"), Organization = OrgName });
if (spCredentials.Success)
{
var res = spCredentials.Result;
if (!string.IsNullOrEmpty(res.Username) && !string.IsNullOrEmpty(res.Password) && !string.IsNullOrEmpty(res.Domain))
{
username = res.Username;
password = res.Password;
domain = res.Domain;
}
}
}
//Set Credentials
nc = new NetworkCredential(username, password, domain);
cache = new CredentialCache();
cache.Add(new Uri(DocURL), "NTLM", nc);
//Create a WebRequest to get the file
fileReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(DocURL);
fileReq.Credentials = cache;
try
{
//Create a response for this request
fileResp = (System.Net.HttpWebResponse)fileReq.GetResponse();
}
catch
{
//Try the credentials from the web.config file
nc = new NetworkCredential(configUsername, configPassword, configDomain);
cache = new CredentialCache();
cache.Add(new Uri(DocURL), "NTLM", nc);
//Create a WebRequest to get the file
fileReq = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create(DocURL);
fileReq.Credentials = cache;
//Create a response for this request
fileResp = (System.Net.HttpWebResponse)fileReq.GetResponse();
}
// Copy the stream to a memorystream so we can seek around it
MemoryStream ms = new MemoryStream();
fileResp.GetResponseStream().CopyTo(ms);
string fileName;
// Faff: Generate a hash unique to the file to use as the name
using (MD5 md5 = MD5.Create())
{
ms.Position = 0;
var hash = md5.ComputeHash(ms);
fileName = string.Concat(hash.Select(x => x.ToString("X2")));
ms.Position = 0;
}
return Groupdocs.Web.UI.Viewer.ClientCode()
.TargetElementSelector("#test")
.Stream(ms, fileName, GetFileExtension(DocURL), GetFileName(DocURL, false))
.EnableRightClickMenu(false)
.ShowThumbnails(true)
.OpenThumbnails(false)
.ShowFolderBrowser(false)
.Height(Convert.ToInt32(Height))
.Width(Convert.ToInt32(Width))
.MinimumImageWidth(Convert.ToInt32(Width))
.SupportTextSelection(false)
.Quality(75)
.Zoom(75)
.ShowSearch(false)
.Layout(ViewerMode.OnePageInRow)
.PreloadPagesCount(1)
.ShowViewerStyleControl(false)
.UseHtmlBasedEngine(false)
.ToString();
Kind regards
Dan