In my Google Chrome extension, I am doing the following:
Creating a text blob:
var file_Blob = new Blob([file_Content], {type: 'text/plain'});
Creating a URL for the text blob:
var file_URL = URL.createObjectURL(file_Blob)
Using the method chrome.downloads.download to download the blob via the URL to a file:
chrome.downloads.download({
url: file_URL,
filename: file_Name,
saveAs: true
});
This has been working fine until the last few weeks / versions (as of 2019/01/07, versions 71 or 70) whereby the downloaded files have been flagged as coming from the Internet.
Security: This file came from another computer and might be blocked to help protect this computer. Unblock
Therefore, a warning window is prompting upon trying to open the files.
File Download - Security Warning
Do you want to open this file?
Name: exampleFile_Name
Type: Unknown File Type
From: exampleFile_Folder
Open Cancel
While files from the Internet can be useful, this file type can potentially harm your computer. If you do not trust the source, do not open this software.
I can't find anything online for this change in behaviour and, as far as I can see, I'm generating and downloading the files as per best practice. Can anyone advise?
Related
I have a .NET app that generates PDFs and XLSes within code, as well as being able to download DOCXs and XLSXes stored in a database table. Edge has no problem allowing me to download (or, for that matter, open in Acrobat Reader / Word / Excel as appropriate) the generated files. However, Chrome does something strange.
When I try to download a DOCX or XLSX, it doesn't give me an option to open it; it just brings up the standard Windows "Save As" dialog box, and when I enter a filename and select "Save," nothing appears to happen. However, Windows Explorer shows the file in its "Recent" list, which makes me think that at least a file entry was created, and then deleted. The file does not appear in Chrome's Downloads page.
When I try to create a PDF, it appears correctly in its own tab. However, when I click on the "Download" icon, first it says that the download failed with a "Network Error," but allows me to resume; when I resume, eventually it says that the download was "Blocked." These download attempts do appear on Chrome's Downloads page.
My Chrome download security setting is "Safe Browsing with Standard Protection." Also, File Handlers is set to, "Web apps can ask to open types of files."
What should I be checking on Chrome to allow file downloads?
Here is the code used to send the file to the web browser:
// byte[] SomeReportContent is the file content
Response.Clear();
Response.Buffer = True;
Response.AddHeader("Content-Disposition", "attachment; filename=SomeReport.pdf");
Response.ContentType = "application/pdf";
// * Other ContentType values:
// application/msword (DOC)
// application/vnd.openxmlformats-officedocument.wordprocessingml.document (DOCX)
// application/xls (XLS)
// application/vnd.ms-excel (XLS)
// application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (XLSX)
Response.BinaryWrite(SomeReport_Content);
Response.Flush();
Response.Close();
Response.End();
It appears that the problem is not with .NET, but with Chrome. When I changed the settings to download PDFs instead of opening them in Chrome's internal PDF viewer, suddenly all of my downloads started working properly.
I am working on an application where a user can create a list, and share it publicly. The contents of the list is rendered by my site as a webpage, but exists also as a text file in the users drive who created it. Everything is handed by javascript, and works well, however I am currently using the https://www.googleapis.com/auth/drive scope.
This is a very scary permission to have, so I would like to drop it. However, when the user trying to read the file, if they only have the https://www.googleapis.com/auth/drive.file scope, the shared file (accessed by id) doesn't exist for them until I run them though the sharing flow.
My guess is that although this was a file created in my application, that file was never opened by the viewing user in my application, so it doesn't qualify under that scope. This seems a bit silly, because anyone (even if they are not logged in as any user) could download the file from google using only its id.
I want to avoid running them through the share-link flow, because if the user hasn't logged into my application yet, they are more or less stranded at that screen. The app isnt installed as a viewer for that filetype for them, so they aren't presented with it as a suggested app to use to open it.
Am I doing something wrong, or is there really no way to support this seemingly very common use case of enabling a user to share links to their files though the app open url?
I dont see why I should need full access to the user's drive as I'm trying to access a file that isn't even in their drive.
Note: I do also have the realtime-api mounted on top of the file, which is also working, but shoudln't really have anything to do with the basic sharing.
Some relevant code snippets creating and setting permissions on the file:
Create The File
gapi.client.load('drive', 'v2', function() {
var insertHash = {
'resource': {
mimeType: 'application/vnd.mysite.com',
title: title
};
};
gapi.client.drive.files.insert(insertHash).execute(next);
});
Grant Everyone Permissions
gapi.client.drive.permissions.insert({
fileId: $scope.id, resource: {
type: 'anyone',
role: 'writer'
}
}).execute(function(resp) {
console.log(resp);
});
Try to access the file as a viewer, fails with out https://www.googleapis.com/auth/drive scope
gapi.client.drive.files.get({fileId: $scope.id}).execute(function(resp) {
console.log(resp);
next(resp);
});
I can find the previous localStorage api data in ~/.config/google-chrome/Default/Local Storage directory. I see that these are sqlite files which I can browse with sqlite3.
However, I'm moving from localStorage api to chrome.storage api and saving the information with chrome.storage.local method.
Now, how and where are these files are bing saved in my file system? I can't seem to find any information regarding this in their doc. Any help would be highly appreciated.
For Windows, you can find different data related to your extension [extension_id] at these places
C:\Users\[user_name]\AppData\Local\Google\Chrome\User Data\Default\Local Extension Settings\[extension_id]
C:\Users\[user_name]\AppData\Local\Google\Chrome\User Data\Default\Sync Extension Settings\[extension_id]
C:\Users\[user_name]\AppData\Local\Google\Chrome\User Data\Default\IndexedDB\chrome-extension_[extension_id]
want to checkout chrome.storage data
open developer tools pointing your background page
type command
chrome.storage.sync.get(null, function (data) { console.info(data) });
or
chrome.storage.local.get(null, function (data) { console.info(data) });
For Firefox which now use the same format as Chrome for addon they are saved here:
C:\Users\Marc\AppData\Roaming\Mozilla\Firefox\Profiles\x5jztslz.default\browser-extension-data\
Can you create a html form that can be housed on a USB flash drive and opened up in a browser that allows someone to enter info and then allows them to save what they entered as a .txt file back to the same USB? Any ideas or resources you can point me to?
Not a full solution, but maybe it gets you on the right track:
Generate a usual HTML page with a form to enter all information necessary.
Then use JavaScript to build a string containing all data you want to store inside the textfile.
Create a Blob() object out of it (MDN docu) - the type application\octet-stream is important to force a download later on:
var myBlob = new Blob( content, { "type" : "application\/octet-stream" });
Convert that blob to a DataURL using window.URL.createObjectURL (MDN docu):
var dataUrl = window.URL.createObjectURL( myBlob );
Update the location of your browser tab using window.location and set it to your data url:
window.location = dataUrl;
The user will then have the usual "Save file as ..." dialog for your generated textfile. Note, however, that this way you are not able to set the name of the textfile!
Not directly. Since this type of form processing has to occur server-side, you need a web server.
Now, it is entirely possible to run Apache or something similar from that flash drive, and have PHP or something do your file writing. This isn't as straightforward as you are looking for, but is possible. Keep in mind that not everyone has autorun enabled, that folks use different OSes, and that firewalls are often picky about new applications opening up ports.
I'm trying to write an HTML5 offline application but can't seem to get Chrome to accept the cache manifest file.
Chrome logs the following output to its console while loading the application:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Error event: Manifest fetch failed (-1) http://localhost/cache.manifest
However, if I remove all lines from the manifest file except for the first line (i.e. "CACHE MANIFEST") Chrome accepts the manifest:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 0)
Application Cache Cached event
But, as soon as I add a new line to the manifest (even if that next line is empty) Chrome reverts to complaining that the fetch failed.
All files are being served locally from a Windows 7 PC via Python using SimpleHTTPServer on port 80. I've updated the types_map in %PYTHON%/Lib/mimetypes.py with the following line:
'.manifest': 'text/cache-manifest',
The manifest should contain the following:
CACHE MANIFEST
scripts/africa.js
scripts/main.js
scripts/offline.js
scripts/libs/raphael-min.js
favicon.ico
apple-touch-icon.png
To cache a website offline (HTML5) you need to specify all the files needed for it to run. In short specify the site main components needed.
Easy way to create a manifest is in Note Pad.
Note: CACHE MANIFEST needs to be first line and your files will follow after a line space as follows:
CACHE MANIFEST
Scripts/script.js
Content/Site.css
Scripts/jquery-ui-1.8.20.min.js
Scripts/modernizr-2.5.3.js
SESOL.png
Scripts/jquery.formatCurrency-1.4.0.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css
http://code.jquery.com/jquery-1.8.2.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js
Content/themes/images/icons-18-white.png
Controllers/AccountController
Controllers/HomeController
Models/AccountModels
Account/Login
Home/CheckOut
Note2: remove all spaces after each line.
Note:3 you need to follow the exact format FOLDER/File or FOLDER/FOLDER/FILE ect....
Just because you have a manifest file doesnt mean it will load. you need to add the following to the Tag:
<html manifest="~/cache.manifest" type="text/cache-manifest">
Don't forget that after you add this it's cached the first time the page loads. So you need to register a cache event in the 'mobileinit' event.
$(document).on("mobileinit", function () {
//register event to cache site for offline use
cache = window.applicationCache;
cache.addEventListener('updateready', cacheUpdatereadyListener, false);
cache.addEventListener('error', cacheErrorListener, false);
function cacheUpdatereadyListener (){
window.applicationCache.update();
window.applicationCache.swapCache();
}
function cacheErrorListener() {
alert('site not availble offline')
}
}
Download Safari and use the web inspector to find errors.
http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/Safari_Developer_Guide/1Introduction/Introduction.html#//apple_ref/doc/uid/TP40007874-CH1-SW1
Tip: Chrome's developer tools "F12" will show you the errors in the manifest load. ie the files you still need to add.
Hope this helps, covers the entire process. I assuming if you are at this stage in development you new to add these to the mobile init:
$.mobile.allowCrossDomainPages = true; // cross domain page loading
$.mobile.phonegapNavigationEnabled = true; //Android enabled mobile
$.mobile.page.prototype.options.domCache = true; //page caching prefech rendering
$.support.touchOverflow = true; //Android enhanced scrolling
$.mobile.touchOverflowEnabled = true; // enhanced scrolling transition availible in iOS 5
Safari Developer Guide:
https://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/Client-SideStorage/Client-SideStorage.html#//apple_ref/doc/uid/TP40002051-CH4-SW4
Have you tried anything like https://manifest-validator.appspot.com/ to validate your manifest?
I've struggled with my manifest file for quite a while, it is really hard to pinpoint what is wrong. Could be something as simple as wrong encoding to an extra line break at the start.
Today I experienced exactly the same problem. After hours of working I came the the key point: the format of manifest file. In short, the file must begin a new line ONLY with ascii(0A), not ascii(0D), or ascii(0D + 0A). Only in this way can I live with Chrome, or I will get a blank page, and the error info in the console window.
According to w3c, (http://www.w3.org/TR/html5/offline.html), in “5.6.3.2 Writing cache manifests”,both 0A, 0D and 0D + 0A are all acceptable. So, my opinion is: Chrome is not compatible with w3c in the point.
Further more, say, if myapp.js is to be cached, it MUST follow the same rule: begins a new line only with ascii(0A), or Chrome will throw the same info in the console windows.
My Chrome is 13.0.782.107
I have now resolved this issue by switching to CherryPy for serving these files :)
If anyone else becomes similarly stuck but wants to keep the server part simple, the following Python may be sufficient for getting started:
import cherrypy
class SimpleStaticServer:
#cherrypy.expose
def index(self):
return '<html><body>Go to the static index page</body></html>'
cherrypy.config.update({
# global
'server.socket_host': '192.168.0.3',
'server.socket_port': 80,
# /static
'tools.staticdir.on': True,
'tools.staticdir.dir': "(directory where static files are stored)",
})
cherrypy.quickstart(SimpleStaticServer())
If you want to visit the "site" from another device, you'll need to use the external IP address (for me this was 192.168.0.3). Otherwise, you can just use '127.0.0.1' for the 'server.socket_host' value. I then point my browser to http://192.168.0.3/index.html to get my static index page.
I have resolved this issue in visual studio for MVC application.
follow below steps:
I have created .appcache file in notepad and copy manifest file content into it.
(you don't need to create .Manifest file OR not create Manifest.cshtml view. just create .appcache file in notepad.)
give reference as
<html manifest="~/example.appcache"> in view
and issue will be resolved
I think the line
CACHE:
is missing in the manifest file (should be the 2nd line, before the list of files.