Offline file viewing - asp.net-mvc

I am working an MVC for project and MSSQL database backend. The project can be view outside even in mobile browser,
This is the workflow, The project have two users the "Admin" and the "User", admin will upload a pdf file and user can view the pdf file that admin upload. Is it possible that when the user is offline or doesn't have the access to the net he can still view the page and can download or view the pdf file.

For showing those PDF file locally when User is offline, You can do one simlest thing is that
1) Store the Files opened today(or in few days) in 'App_Data' folder.
2) Write some process in your server side to check whether the PDF file is present in App_Data or not.
If(File present in App_Data Folder)
{
//We Can Open that PDF File Locally
}
else
{
//Stream those PDF Files and store it in App_Data for further use.
}

Related

How can I access the contents of a folder selected from Files app?

Basically my app works like a iCloud-based note app (for example, logseq). Users first select a folder in Files app, then my app starts downloading/updating the contents of the folder.
So I implemented folder selection via UIDocumentPickerViewController, after I got the folder path in Files app. I tried downloading a hardcoded file like (<the folder path user just selected>/fileList.json) via FileManager.startDownloadingUbiquitousItem, got 257 permission error (the file does exist in my icloud drive). Then I followed the answer from this answer to call startAccessingSecurityScopedResource. It always returns false and the same 257 error returned.
Perhaps, I cannot access a random file from a selected folder? but how can those note apps work by simply letting users selecting a root folder?
Answering my own question after some debugging. Call startAccessingSecurityScopedResource on the folder path you grabbed from picker, not its subfiles. After that, you can start downloading its subfiles via startDownloadingUbiquitousItem

How to open or download pdf files

I have an app what do querys from my sql database and i need to download or open files from the database. The files route are saved in the database so i need a way to download it or open in the app.The files type are pdf and jpg.

prevent direct url access to files inside storage folder in laravel 5

I'm developing an apllication in laravel 5.4
There are many pdf and other documents inside storage directory under laravel root directory. Now anyone can view or download these files using the url to that file.
eg: http://localhost/ssrteam/storage/app/hei/clarificationfiles/100013_227.pdf
I want to restrict the access to all files under storage from unauthenticated users. Only logged in user should see the files even with direct url

Web view UWP not loading files in the machine

can I open a html file on the C drive or on any location using the web view in UWP?
I am using the following code but it is not working:
Uri targeturi = new Uri("C:/Users/user/Pictures/Files/Forms/dac36cac-5d83-4fae-bf4f-112361b719ea/index.html");
browser.Navigate(targeturi);
In uwp files have limited access permission. By the default the app can only access the application install directory and data locations. Additional locations require special capabilities. More details about file access permission please reference this document.
You can gain access to files and folders on a removable device by calling the file picker (using FileOpenPicker and FolderPicker) and letting the user pick files and folders for your app to access. Learn how to use the file picker in Open files and folders with a picker.
According to your code snippet, you want to access the HTML file inside the picture folder. For accessing file in picture folder please reference Files and folders in the Music, Pictures, and Videos libraries. Pay attention on the Capabilities page, select the libraries that your app manages. So the correct way to open the file and show it in the WebView may as follows:
StorageFolder storageFolder = await KnownFolders.GetFolderForUserAsync(null /* current user */, KnownFolderId.PicturesLibrary);
StorageFile indexFile = await storageFolder.GetFileAsync("index.html");/*Change to your file path inside the picture folder*/
browser.NavigateToString(await FileIO.ReadTextAsync(indexFile));
You may find I used the NavigateToString method. The Navigate(Uri) method can not navigate to a file by path directly. To load uncompressed and unencrypted content from your app’s LocalFolder or TemporaryFolder data stores, use the Navigate method with a Uri that uses the `ms-appdata scheme, to HTML content in the app package using the ms-appx-web scheme. For example:
webView1.Navigate("ms-appx-web:///help/about.html");
More details please reference "Navigating to content" of WebView. And the scenario 5 of the official sample provide samples about navigating to file you can reference.

Display docx or ppt in browser with ruby

I'm currently working on a intranet webapp for a company.
I've created it so the administrators of the site are able to upload files
(.docx, .pdf, .xlsx, .ppt etc) up to the webapp, to provide easier access
to documents for the employees. It works very well, however my client wasn't
too fond of having to download the files, and wanted it to pop up in the browser,
or open up the file-spesific program instead of download.
I was playing with some ideas:
1. Somehow parse the files to JSON at upload, and then show the content in browser with html.
2. Generate a pdf from the uploaded file (which automatically launches in the browser).
3. Somehow use a previewer to show the filecontent in the browser
4. Clients computer launches the uploaded file automatically on download, however I think this is a bit more tricky...
What would be the best and most time-efficient way to go about this?
It feels like what you actually want/need is a javascript document viewer (only) such as http://viewerjs.org/.

Resources