I have a file hosted on AWS Linux AMI. The link is http://54.179.188.146/a/a.docx I can visit the link and download the file.
I am trying to use Microsoft Online Doc Viewer to view the Word File online at this link https://view.officeapps.live.com/op/view.aspx?src=http://54.179.188.146/a/a.docx but it returns a page stating "An error occurred We're sorry, but for some reason we can't open this for you."
I had chmod the file to 775 but it still cannot view.
I had uploaded to another server and it is working. May I know what is wrong? Is it a server configuartion issue? Please advise.
Thanks.
This is Old but giving some more pointers to the new visitors , i am posting the consolidated answer for the root cause of the "We’re sorry, but for some reason we can’t open this for you" error in https://view.officeapps.live.com/op/view.aspx?src=
If you see the error, "We’re sorry, but for some reason we can’t open this for you," it means the document could not be found or could not be displayed. Likely reasons include:
There’s no document to be found at the URL you provided. Make sure
you provide the correct URL.
The document is too large. Word and PowerPoint documents must be less
than 10 megabytes; Excel must be less than five megabytes.
The document was not saved in a format that is supported for opening
in a web browser. Try saving your document in one of the following
formats:
Word: docx, docm, dotm, dotx
Excel: xlsx, xlsb, xls, xlsm
PowerPoint: pptx, ppsx, ppt, pps, pptm, potm, ppam, potx, ppsm
You need to sign in or provide a password to open the document. Make
the document publically available to view.
The document’s file name contains invalid characters. Try encoding
the file name when you type the document’s URL, or rename the file to
use only letters and numbers. For example, to encode a URL that
includes an ampersand (i.e. &), you would type %26 for the ampersand
character. For more information about URL encoding, also known as
percent encoding.
more info can be found here
The value after "src=" should be URL-encoded. See details on MS Page
You should checked all reasons from here
There’s no document to be found at the URL you provided. Make sure you provide the correct URL.
Try to open file from browser.
Make sure you don't try to send on preview service path of the file from your local host. To which, obviously, there is no access from the Internet.
Path to file must be http:// or https://
If path to your file start with https:// make sure your site have necessary secure certificate.
Domain name matters.
Will not be open in preview service
http://185.231.70.200/vacuumcleanerprocedure.doc
Will be open in preview service
http://domainname.com/vacuumcleanerprocedure.doc
The document is too large. Word and PowerPoint documents must be less than 10 megabytes; Excel must be less than five megabytes.
Try different files with different Microsoft file types.
The document was not saved in a format that is supported for opening in a web browser. Try saving your document in one of the following
formats: Word: docx, dotx Excel: xlsx, xlsb, xls, xlsm PowerPoint:
pptx, ppsx, ppt, pps, potx, ppsm
Try different files with different Microsoft file types.
You need to sign in or provide a password to open the document. Make the document publicly available to view.
File permission and folders mode should be 775.
Check if in .htaccess file of your apache server there are allow access to ms-office files.
Check if your file available from internet. Try to open file from browser. If you see “You don't have permission to access filename on this server” see answer here
The document’s file name contains invalid characters. Try encoding the file name when you type the document’s URL, or rename the file to
use only letters and numbers. For example, to encode a URL that
includes an ampersand (&), you would type %26 for the ampersand
character. For more information about URL encoding, also known as
percent encoding, see Percent-encoding on Wikipedia.
The value after "src=" should be URL-encoded. When you place the link on the preview service, it already encodes it for preview. Additionally, I may encode the link here, but the result will be the same.
Related
I'm doing a computing assignment, and I read this passage and had no clue. I don't get the full picture behind what MIME-type are...
"Note that filelename extensions are not the same as file types. Some filesles may end in .html or .htm but
the header indicates that the MIME-type is text/plain. On the other hand, a file may have an extension
.txt - or no extension - but have a MIME-type of text/html. The MIME-type defines the true type
of the file."
What do you mean by the MIME-type defines the true type of file?
Thank you so much!
I can give a self-learning experience
in windows open Registry Editor
Start -> Run -> regedit
Expand HKEY_CLASSES_ROOT
choose any extension you want say (.pdf)
you can understand how is it related and how it is treated
Again expand .pdf, you can see through which application it is usually processed
this makes a perfect learning experience of various MIME types and its content type and which application it is as default processed
MIME type is not only determined by the ending of a file, it also refers to the content in the file i.e. a python script s.py has MIME type text/x-python, while an empty file named s.py has inode/x-empty on a linux system
In linux use file --mime-type FILE_NAME command
How can I find out a file's MIME type (Content-Type)?
MIME types are just a way to identify the type of a file. Typically, there are two ways to figure out what the type of a file is:
Look at the file extension. For example, a pdf is usually saved as file.pdf ending with the extension pdf. This is a hint that the type of the file is pdf file. However, you can change the name of the file and simply change its extension to something else. So, the name of a file does not necessarily have to indicate its type
Look at the contents of the file and try to guess based on how its arranged in binary.
Most binary files have very specific representation inside a file. For example, if you open a pdf file in a notepad (or any text editing program), you will find that it starts with %PDF-. Followed by some numbers and potentially weird characters. This tells you that this is a pdf type.
Why is this useful? Files are simply saved as blocks of binary data. However, certain files can only be opened by certain programs (for example, music files can't be "opened" by text editors, it can only be played with a music player). By figuring out the MIME type of a file, you can understand how to interpret the data in the file (for example, text, image, video, audio are common mime types). Then, you can use the correct software to use the file.
How does Chrome determine the name of the file being saved to disk when downloading a file?
Whenever I download a file from a particular website I am working on (as a developer), Chrome is appending an underscore to the end of the file extension. (See: Chrome on Windows adding trailing underscores to downloaded files? ). I've been playing around with various content-type and content-disposition headers, and it appears that Chrome is ignoring the filename specified in the Content-Disposition header. For example, if I make a request to download a file, and the response comes back with the following headers (among others):
Content-Disposition: attachment;filename="example.pdf"
Content-Type: application/pdf
... the name of the file saved to disk is still the original file name. In this example, the original file is named test.pdf, and rather than saving it as example.pdf (as specified in Content-Disposition), it is being saved to disk as test.pdf. This seems to hold true for any sort of file type - even something as simple as a .txt file. There doesn't appear to be any other HTTP response headers dictating the file name.
Is there something special that Chrome does to determine the name of the file being saved to disk? If so, is it possible to override this behavior?
I understand that Chrome will rename certain downloaded files that it sees as a security risk (e.g.: renaming .lnk to .download), but even in a case like this, it is still ignoring my Content-Disposition headers for safe file types.
I have a form that will open a file based on user's selections. A few files are .csv and those files open up in Excel, as expected. However, everything is placed into one cell... I know that there is a way to manually configure it so that the | or , are delimiters, but is there a way to set it so that Excel will automatically set the | as a delimiter?
Thank you in advance!
Because you use the word "download" and your question is tagged "html", I assume that the user interacts with a web form rather than a desktop form.
In that case, it's the web browser that decides what to do with the file. If the browser recognizes the content-type of the response as something it can handle natively (e.g. "text/plain" or "image/jpeg") then it may open the file and display it directly.
However if the content-type is not something it knows how to deal with (which is likely the case with "application/csv"), then it will download the file and ask the operating system to open it. At that point, the filename assigned to the file (which can be set via the HTTP response) may come into play.
On a Windows machine, the operating system maintains a list of file extensions and actions associated with those extensions. When you install Excel, that will normally make Excel the default "open" action for files with the ".csv" extension. That's why double-clicking on a ".csv" file opens in Excel, and also why it may open in Excel if you download it from a website. (If you didn't have Excel, it may simply ask you what program you want to use).
This is a long-winded way of saying that if you had control over the user's machine you could give the file a different file extension and then associate that extension with an action that did something different. But, I assume that you probably don't have that sort of control unless you're dealing only with in-house users, and anyway it would not be a trivial thing to achieve.
I don't think that there's any way to communicate to Excel via the command line that it should use a particular delimiter when opening a CSV file, and that - unfortunately - is the mechanism by which the operating system will ultimately open the file.
It is possible to control what Excel uses as the default delimiter for all CSV files (see https://superuser.com/a/606274/18472) but again that would require you to change the system-wide settings on your users' machines, which I imagine would not be possible.
I have a link which points to a CSV file. When clicked, it opens the file in the browser. I would like to use a different application (i.e. Excel, Open Office, Lotus) to open the file as a spreadsheet. Is it possible to include headers or something to make this happen? Thanks
Link:
<a target="_blank" href="contacts.csv">Contacts</a>
Browser Displays:
First Name,Last Name,Title,Email,Company,Address,City,State,Zipcode,Direct Phone,Mobile Phone,Direct Fax,Company Phone,Company Fax
John,Doe,Estimator,johnd#acme.com,Acme Co.,112 Main St,Gothem,IL,,(847) 555-1122,,,,
Jane,Doe,Engineer,,Ace Industries,,Seattle,WA,,,,,(206) 555-1234,
You will need to set the content type header on whatever generates the csv file.
See: Setting mime type for excel document
For the available headers.
You don't say which language you're using to generate the csv data, or whether it's simply a flat file you're linking to. While most languages will provide the means to set headers on the fly, if you are using static flat files, you may need to set your htaccess (assuming apache is your web server). There are instructions for that case here: http://htaccess.wordpress.com/2008/07/16/sending-correct-content-type-headers-with-htaccess/
The answer that #stakolee links to is really more specific to opening a file in Excel. If you want to be correct and widely compatible, the mime type should be for CSV, not Excel.
The correct mime type is text/csv. Excel will likely be the application associated with this type, so you'll get the behavior you want.
What MIME type should I use for CSV?
You cam also set Content-Disposition to help things along.
Content-Disposition: attachment; filename="filename.csv"
What to set as mimetype for CSV files to open in spreadsheet applications
If you want backup options, you can set multiple mime types.
text/csv, application/csv, application/excel, application/vnd.ms-excel, application/vnd.msexcel
Filepicker does not accept mimetype 'text/csv' on windows
RFC 4180 says you can respond with text/csv; header=present or header=absent to indicate if the files contains column headers.
Proper syntax for optional header parameter for text/csv mimetype?
(I am sorry if my question is not in the right place. (I've been thinking for awhile and came up to the conclusion that this one is the best place for my question)
Is it possible to create such an HTML web-page that would provide a user to download a certain file from it, but would not disclose the location of that file (i.e. the user would not know the URL of the file that he is downloading).
If yes, would you, please, give me some directions as to which HTML code I should use to create such a page.
The HTML page would provide a link to a server side script passing a filename or other unique moniker:
Download Now
The script would read the identifier, derive a full path from it, load the file and write it back with the appropriate headers/mime type causing the browser to prompt the user with the normal download dialog.
The only location data available to the user would be the link to the script - which would - unless you add some security - serve back the file just as if it were a standard url pointing to a file.
(PHP Example)
With pure html, no. But with a serverside script (php, c#, vb, perl, or other) yes. You would stream the file to user. In that case just the serverside script has access to the origin files