Create folder from chrome extension - google-chrome-extension

I am developing chrome extension where I am trying to create a folder from extension to save some of the files. I believe there are some security constraints for this but I am not sure if this can be done if yes could someone please guide me how to do this? I have tried FileSystem APIs but I was not able to physically see where the file was created and access it.
Thanks in advance.

The html5rocks article gives an overview of how to create all of this.
This is how you create a directory
window.requestFileSystem(window.TEMPORARY, 1024*1024, function(fs) {
fs.root.getDirectory('MyPictures', {create: true}, function(dirEntry) {
...
}, errorHandler);
}, errorHandler);

Related

Changing localhost:9002 for exposing API

I am trying to get the api working on an Azure VM. The url won't be https://localhost:9002/rest/v2/ext/basestores/ext anymore, but otherUrl:9002/rest/v2/ext/basestores/ext.
Could somebody tell me where to look for that?
Many thanks :)
Not sure if I got your question correctly, but at least from Spartacus point of view, you can define backend.occ.baseUrl configuration to any URL you need.
Here is the basic example:
B2cStorefrontModule.withConfig({
backend: {
occ: {
baseUrl: 'https://localhost:9002',
prefix: '/rest/v2/'
}
},
}),
And here are docs how to set-up Spartacus:
https://sap.github.io/cloud-commerce-spartacus-storefront-docs/building-the-spartacus-storefront-from-libraries/#adding-import-declarations-and-storefront-configuration-settings
Nothing to do with hybris. In your hosts file add an entry-
127.0.0.1 otherUrl

React Native has something to use local folders as 'package name'. What is it called?

It's kind a strange question, but you can probably help me!
In React Native you can add a package.json file to your config folder for example with the content:
{
"name": "#config"
}
Later on, everywhere in your project (no matter how many folders deep), you can load any config-file using import http from '#config'.
Can anybody tell me how this is done, and how this is done? I really want to do this in my own Node.js project :)
Thanks in advance!
Bob
If you plan to publish your package, the most important things in your
package.json are the name and version fields as they will be required.
When you create a new package.json and named it as {"name": "#assets"}, Now you are exposing your image dictionary assets as a module. So your question is answered -how this is done? And for accessing do this import Images from ‘#assets/images’; in components. Read more here

Can I set extension policies locally from the registry?

I have a Chrome Extension and I added a managed_schema to define a property (SomeSetting) so I can set it via a policy.
manifest.json:
"storage": { "managed_schema": "schema.json" }
schema.json:
"properties": { "SomeSetting": { "type": "string" } }
I can see SomeSetting in chrome://policy/ but I have no idea how to set the value. Apparently I can do this at HKLM\SOFTWARE\Policies\Google\Chrome\3rdparty\extensions... but I tried and it never is shown as set in chrome://policy/.
Does anyone know if this is suppose to work? Does it have to be HKCU instead? Or do I need Active Directory because setting values locally via the registry is not supported?
I had a hard time figuring this out. The documentation is not all that clear.
In order to get your schema to work you need to add a registry entry for "SomeSetting".
Go to the following item in your registry (create the necessary items):
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\3rdparty\extensions\aaaaaaaaaaaaaa\policy
where aaaaaaaaaaaaaa is your extension ID from chrome://extensions
Right-click on "policy" and create a new string value:
Name: SomeSetting
Data: "some value"
Go back to Chrome and reload chrome://policy/
The new policy should appear.
From your extension, you can access the value like this:
chrome.storage.managed.get("SomeSetting", function(setting_val) {
console.debug(setting_val);
});
I'm not sure if this requires Active Directory to work.
It was mentioned in Alternative Extension Distribution Options that:
Google Chrome supports the following extension installation methods:
Using a preferences JSON file (for Mac OS X and Linux only)
Using the Windows registry (for Windows only)
More information regarding other mechanisms on extensions distribution options can be found in the documentation.

Changing the default Sails public folder

I know from experience that Sails creates a ./.tmp/public/ folder from where it serves all my files. I'd like to change it to just ./public/
I read a GitHub issue that said I could do it in config/local.js, but that doesn't seem to be working. Here's the GitHub issue: https://github.com/balderdashy/sails/issues/709
Is there a way to accomplish this? Thanks.
As to why I'm trying to do this, it's because I'm actually trying to work with Sails and Parse to build a simple test application. Since Parse looks in the ./public/ directory by default and I couldn't find a way to change this behaviour, I'm trying to configure Sails.
Create a file config/paths.js with the value:
module.exports.paths = {
'public': 'assets/'};
As in the mentioned issue report it can either be done in the .sailsrc file
{
"paths": {
"public": "bar/foo"
}
}
or if you launch sails in your own app (no using sails lift)
var Sails = require('sails');
Sails.lift({
paths: { public: 'mydir/pub' }, // relative to appDir
}, function(err, server) {});
If your using out of the box Grunt tasks, then you will need to go through and edit those tasks in <root>/tasks/config, there does not seem to be an global config variable for this, so you might have touch each file.
http://sailsjs.org/documentation/anatomy/my-app/tasks/config

Drag 'n' Drop files to a Chrome Package App?

Has anyone successfully implemented drag and drop with files from desktop to the app?
I've tried just putting this drag 'n' drop example into the index file but I just get this error:
Can't open same-window link to "file:///C:/Users....whatever"; try target="_blank".
Please share your stories, what you've tried and if you have succeed :)
Some resources to help you:
New Chrome Packaged Apps codelab that we've been working on covers drag-and-drop in both AngularJS and pure JavaScript.
AngularJS drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/angularjs/2_drop_files
JavaScript drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/javascript/2_drop_files
There's an early version of docs too for AngularJS drag-and-drop for Chrome at developer.chrome.com/trunk/apps/app_codelab5_data.html#handle_drag_and_dropped_files_and_urls
We're working on the docs to cover both samples though.
I have done this a while ago and it worked.
The problem you've got is that you are creating a file url, then trying to navigate to the url. The navigation is failing, not the read. It's failing due to CSP, and you probably won't be able to override that with a different CSP due to security restrictions we've placed on allowable CSPs.
But, you should be able to just read the file and use the content. You need to change that sample code to use ReadAsText or ReadAsArrayBuffer instead of readAsDataURL. Look here for more details.
Please let us know how you get on!
Just listening for drop won't work. You will have to prevent the default functionality of dragover.
document.body.addEventListener('dragover', function(e) {
e.preventDefault();
}
document.body.addEventListener('drop', function(e) {
alert('it works!')
}

Resources