DapperDev_ on Wed, 16 Mar 2016 13:27:43
I am using the following code to try to open a file using CSOM:
So I load the file then get the fileInfo then read the stream data and return. Am i missing a step now to open this file? I do not want download, I just want to open as we are using the permissive setting of SharePoint.
F van Lill on Wed, 16 Mar 2016 14:58:58
In order to view a file the file is downloaded to the user's machine regardless. (It actually gets downloaded to the internet temp location if you choose the "Open" option instead of "Save").
I use the below code to open my document's in the browser.
Also you need to know which application should open the file.
So you need to read the file extension and depending on which type it is use: application/[Type]
A list of all MIME types can be found here: https://msdn.microsoft.com/en-us/library/bb742440.aspx
Note that FileResult is an ASP.NET MVC namespace and can be instantiate by calling the System.Web.Mvc namespace.
Code example are:
FileResult fileResult = new FileContentResult(data, "application/pdf");
fileResult.FileDownloadName = fileName;
DapperDev_ on Sun, 20 Mar 2016 14:07:46
Thank you so much!
DapperDev_ on Tue, 22 Mar 2016 19:05:33
Hi, do you know how I can edit the file and re-save this back to SharePoint??
Can we save the file to our App_Data folder, open and once SAVE is selected, catch this event in MVC?? If so, I could then easily upload the file back to our document library.