I am having a similar problem to MicrosoftOfficeEditDocument didn't work in Chrome.
I did download the updated library as said in the answer and it works fine with Office 2013 but not with 2010.
With Office 2010, I have some files that open and some that don't, they are not always the same ones. I tried with .doc, .docx, .ppt, .pptx, .xls and .xlsx.
I call the edit document fonction with :
ITHit.WebDAV.Client.DocManager.EditDocument(sDocumentUrl, javaAppletFilePath);
EDIT :
It actually seems to be a problem of length of file url. When my file url (sDocumentUrl) is longer than the length of my script url in which I call EditDocument it works perfectly fine. But when it is shorter, the end of the script url is added after sDocumentUrl which makes the call fail. And this only happens with Chrome and Office 2010.
Any way to make this work ?
Add '\0' to the end of the URL
Add a '\0' (null) to the end of the string you are passing to MicrosoftOfficeEditDocument(). Like MicrosoftOfficeEditDocument(path + '\0');. Also, you should use MicrosoftOfficeEditDocument() instead of EditDocument() because EditDocument() will try to call JavaEditDocument() because of the null terminated string.
This is a solution taken from here - https://code.google.com/p/chromium/issues/detail?id=269183#c5
For more info - opening webdav files in Chrome via the Office Authorization plug-in for NPAPI browsers fails for certain files
Check for ActiveX first
However, you should not add the '\0' to the path when MicrosoftOfficeEditDocument() will open the document via the SharePoint.OpenDocument ActiveX object or else the ActiveX plugin will not recognize the file format via extension and try to open the document via undefined:ofe|u| instead of ms-word:ofe|u| for example. To do this you should check for ActiveX before appending the '\0'.
if (!('ActiveXObject' in window)) {
path = path + '\0';
}
ITHit.WebDAV.Client.DocManager.MicrosoftOfficeEditDocument(path)
Warning: this solution breaks MicrosoftOfficeEditDocument in Firefox. Firefox does not like the \0 terminated string.
Related
I want JSON files and downloads to be displayed directly in the IE browser -- Browse in Place.
There are many posts that describe the technique of setting the CLSID value for application/json in the browser.
For example:
How can I convince IE to simply display application/json rather than offer to download it?
I have tested on IE 11 (11.0.9600.17416) and Windows 10.
I changed the setting and even then rebooted, but I am always prompted to download the JSON.
EDIT:
After running the script to alter regedit, I see the following:
I try to refer the answer in that referenced thread.
I made this test on Windows 10, IE 11 (11.1.18362.0) version.
I simply try to refer the steps below.
(1) Try to open Notepad and paste the code below in it.
Windows Registry Editor Version 5.00
;
; Tell IE to open JSON documents in the browser.
; 25336920-03F9-11cf-8FD0-00AA00686F13 is the CLSID for the "Browse in place" .
;
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\application/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
[HKEY_CLASSES_ROOT\MIME\Database\Content Type\text/json]
"CLSID"="{25336920-03F9-11cf-8FD0-00AA00686F13}"
"Encoding"=hex:08,00,00,00
(2) Save the File with name as json-ie.reg
(3) Double click the file to run the script and allow it to create a key.
(4) Try to double click the json file and it opens in IE 11 without any issue.
Output:
I've got a rather odd situation happening, that I'm having difficulty tracking down in an existing Django application. One of the views, which inherits from APIView, returns with a file when a user makes a POST call. The endpoint works fine, but there's something odd happening when the downloaded file reaches the client machine. By the time the browser receives the file, the file extension has been renamed with a trailing underscore. (So suppose the file was originally "test.txt", the version that the client receives would be "test.txt_").
As near as I can figure, just before the response object is returned in the APIView, the content-type and content-disposition headers look correct. E.g.:
Content-Type: application/octet-stream
Content-Disposition: attachment;filename="test.txt"
That same file, when it shows up in Chrome downloads, is named "test.txt_" - with the trailing underscore. I've tried the same thing out in Firefox, and it seems to download correctly. Unfortunately, telling the majority of our users to switch browsers isn't going to fly.
I have tried:
Forcing a different content type (e.g.: instead of "application/octet-stream", try "application/text", just to see what happens). This had no effect.
Formatting the content disposition slightly different (e.g.: space between the semicolon and filename). This also had no effect.
Removed the double quotes around the filename in the content-disposition header. No effect.
Dropping breakpoints within the Rest Framework itself, but Visual Studio Code doesn't seem to trigger on these. (I'm not super-familiar with debugging through Visual Studio Code, so this may be my fault).
Stripped out any custom middleware, so the only remaining middleware are as follows:
corsheaders.middleware.CorsMiddleware
django.contrib.sessions.middleware.SessionMiddleware
django.middleware.locale.LocaleMiddleware
django.middleware.common.CommonMiddleware
django.middleware.csrf.CsrfViewMiddleware
django.contrib.auth.middleware.AuthenticationMiddleware
django.contrib.messages.middleware.MessageMiddleware
So far, any similar issues that other people have experienced seem to be slightly different (i.e.: Internet Explorer removing the period in the extension and replacing it with an underscore).
Any guesses on what might be happening here? I'm a bit stumped.
You have to remove "" from your file name
Change attachment; filename="filename.txt" to attachment; filename=filename.txt
Although seems like you won't be able to have spacing in file name
I finally figured out what was going on here. The UI that was used to trigger the download was doing so through creating a temporary anchor tag (see the second answer here: Download data url file ). When it was doing so, it had two different cases. In one case, if downloading multiple files, it would change the file extension to .zip. In another case, if downloading a single file, it was still trying to append an extension, but the way the UI code was written, it was setting the extension to be an empty string. So the end result is a period being added, but no extension after that. For example, if the file being downloaded was "test.txt", it would end up as "test.txt.", which was then converted by Chrome to "test.txt_", on Windows, to make it a valid file extension.
Our environment has a document storage system that contains documents with the attributes DocumentName and ContentType. In some cases, the content type would return with spaces appended to the end of the string like "pdf ".
In Internet Explorer the output would truncate the end of the string while Chrome would convert the extra spaces to underscores giving me this filename: "file.pdf______________"
To resolve I simply truncate the string.
public string getFileName(string docName, string contentType) {
string fileName = docName + "." + contentType.Trim();
return fileName;
}
I encountered the same problem.
Let's say your download file name is "my_report.csv"
Then before doing the download operations get rid of " characters
fileName = fileName.replace('"','') // replacing one " charcter
fileName = fileName.replace('"','') // replacing second " character
This will resolve your issue.
My solution in ASP.NET core
[HttpGet("pdf/{fileId}")]
public IActionResult GetPdfFile([FromRoute]int fileId)
{
var result = Repo.GetFile(fileId);
Response.Headers.Add("Content-Disposition", $"inline; filename={result.FileName}");
return File(result.Data, "application/pdf");
}
I resolved this issue with replace white space in file name by a character like -.
This was happening for me when the filename included a comma.
lastname,MD.pdf
browser would download filestream as
_lastname,MD.pdf_
Adding code to remove a potential comma from the filename resolved the issue and made it download as expected.
filename = filename.Replace(",", ""); // replace comma characters with blank
now downloads as
lastnameMD.pdf
In my case there was a space as a first character, and it was replaced to underscore. So I simply removed the space :-)
I added this HTML to a page that I render via a REST call:
StringBuilder builder = new StringBuilder();
. . .
builder.Append("<p></p>");
builder.Append("<a href=\"/App_Data/MinimalSpreadsheetLight.xlsx\" download>");
builder.Append("<p></p>");
. . .
return builder.ToString();
My ASP.NET Web API project has a folder named "App_Data" which does contain a file named "MinimalSpreadsheetLight.xlsx"
The download link is indeed rendered on the page, and clicking it does appear, at first, to download the file (it has the Excel icon, and it bears the file name), but beneath that it says "Failed - No file":
Is the problem with my HTML, or the path I'm using, or file permissions, or what?
I've only tested this with Chrome, so far, BTW. IOW, it's not an IE issue.
UPDATE
I tried it with a leading squiggly, too:
builder.Append("<a href=\"~/App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Spreadsheet file\">");
...yet, alas, to no avail.
UPDATE 2
I changed the pertinent line of HTML to this:
builder.Append("<a href=\"App_Data/MinimalSpreadsheetLight.xlsx\" download=\"Minimal Spreadsheet file\">");
...and it displays in the source like so (with some context):
<p>(Invoice Count excludes credits and re-delivery invoices)</p><p></p><p></p><a href="App_Data/MinimalSpreadsheetLight.xlsx" download="Minimal Spreadsheet file">
...but the link does not appear at all.
UPDATE 3
I was misled by this reference, which showed no text being added; I changed the code to this:
builder.Append("Spreadsheet file");
...(adding "Spreadsheet file" and closing out the anchor tag), and now the link appears; however, I still get the "Failed - No file" msg, and 2-clicking the "downloaded file" does nothing.
UPDATE 4
I tried two other permutations of what's seen in Update 3, namely with the forward whack reintroduced prior to "App_Data":
builder.Append("Spreadsheet file");
...and with both the squiggly prepended and the forward whack:
builder.Append("Spreadsheet file");
...but the results are the same in any of these permutations ("Failed - no file").
UPDATE 5
I also tried it without the "App_Data" at all, on the off change that is not needed:
builder.Append("Spreadsheet file");
...but the same "Failed - No file" is the result of that attempt, too.
UPDATE 6
Okay, so I tried this, too (single quotes):
builder.Append("<a href='/App_Data/MinimalSpreadsheetLight.xlsx' download='Minimal Spreadsheet file'>Spreadsheet file</a>");
...but no change. The file is there:
...so why is it not seen or accessible?
UPDATE 7
This:
string fullPath = HttpContext.Server.MapPath("~/App_Data/MinimalSpreadsheetLight.xlsx");
... (which I got from here) fails to compile with, "An object reference is required for the non-static field, method, or property 'System.Web.HttpContext.Server.get'
2-clicking the err msg highlights just "Server"
UPDATE 8
This (which I got from the same place as what I tried in Update 7):
string justDataDir = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
string url2 = string.Format("Spreadsheet file</button>", justDataDir);
builder.Append(url2);
...does nothing; clicking the link doesn't even give me a fake/failed download now...
justDataDir is:
C:\Projects\ProActWebReports\ProActWebReports\App_Data
url2 is:
Spreadsheet file</button>
UPDATE 9
I noticed on further fine-tooth-combing that url2 had a forward whack in it; I changed it so that all the whacks were back, but it made no difference to Update 8's results: clicking the link does nothing whatsoever.
If somebody solves this, it will definitely get bountified after the fact.
UPDATE 10
Maybe what I really need to do is, instead of the simple html, add some jQuery that will download the file. But the question is, can jQuery access the App_Data folder any better than raw/simple html can?
The app_data folder is used by iis and asp.net as a private area in which to put database files which can only be accessed by code running on the server.
If you try to access the folder directly via your browser you will get a permissions error.
In order to make the files available for download, move them the a folder under 'Content' (if you have an mvc site) and ensure that your web.config allows the .xlsx exention to be downloaded.
It may depend on what version of iis you are using.
Downloading Docx from IE - Setting MIME Types in IIS
I'm trying to find a way to make a shortcut for Google Chrome that will open multiple IP based links in multiple tabs.
I have this line of code in the .bat file.
#echo off
start Chrome “111.95.192.176/Audit/WebPages/Login.aspx”
start Chrome “111.95.192.176/AirAudit/WebPages/Login.aspx”
start Chrome “111.95.192.176/Helpdesk/Login.aspx”
start Chrome “111.95.192.176/SPM_Audit/Login.aspx”
But in Google chrome it display some error after open the batch file (.bat)
This site can’t be reached
xn--http-uqa’s server DNS address could not be found.
ERR_NAME_NOT_RESOLVED
How could I resolve this error?
Note: In code IP address is not original one.
Command START interprets first double quoted string often as title string. Therefore it is advisable to explicitly define a title string which in case of starting a GUI application is simply an empty string.
Command processor interprets only straight double quotes " as double quote with special meaning. All other double quotes are interpreted literally.
To open multiple pages in Google Chrome specify all the URLs as arguments on one command line.
#echo off
start "" chrome.exe "111.95.192.176/Audit/WebPages/Login.aspx" "111.95.192.176/AirAudit/WebPages/Login.aspx" "111.95.192.176/Helpdesk/Login.aspx" "111.95.192.176/SPM_Audit/Login.aspx"
Of course there is no need to use a batch file at all as you can specify in shortcut chrome.exe with full path in double quotes and the URLs to open as arguments directly.
PS: Not tested with Google Chrome has I don't have this browser installed.
Got the correct code:
#echo off
start "" http:\\111.95.192.176/Audit/WebPages/Login.aspx
start "" http:\\111.95.192.176/AirAudit/WebPages/Login.aspx
start "" http:\\111.95.192.176/Helpdesk/Login.aspx
start "" http:\\111.95.192.176/SPM_Audit/Login.aspx
NOTE: Google Chrome is default web browser.
Given a url, my application tries to download the file, e.g., http://foo.com/bar.bat will download bar.bat
Now, given a version number at the end delimited by semi-colon, my application will retrieve that particular version from my source control and download the file.
For e.g., http://foo.com/bar.bat;1 should download bar.bat version 1.
http://foo.com/bar.bat;2 should download bar.bat version 2 etc.
Problem:
Chrome downloads the right version as bat file.
IE (am using IE 11) and firefox downloads the right version but considers 'bat;1' or 'bat;2' as the file type instead of 'bat'.
I have mime type as application/bat. I tried with '%3b' instead of ';' but same issue.
No idea what else to check.
Any help would be appreciated.
Why don't you use http://foo.com/bar.bat?version=1 instead? this should work on every browser properly because it is a standard.
I resolved the issue by making a code change in Perl (with Google's assistance, of course).
In case, anyone intererested or face this problem in future, here is what i did.
In perl code, redirect to http://foo.com/bar.bat;1 was happening with relative path.
print $query->redirect(-uri => $redirect); # $redirect being '/bar.bat;1'
I gave absolute path like below
my $RemoteHost = $query->url(-base=>1); #this gets http://foo.com
my $newredirect = "$RemoteHost$redirect";
print $query->redirect(-uri => $newredirect);
I will mark erikvold's as answer since he triggered me to look at the perl code.
Thanks Jonathan and erikvold.