How do I get the absolute path of the chrome extensions directory? - google-chrome

I'm writing an app that has full access to the file system and I want to be able to get the absolute path of my extension's directory. How would I do this?
My app has permissions to "<all_urls>", {"filesystem": [ "write" ]} and has the "allow access to file urls" checked.

If you mean the file system path, that differs on each operating system. You can find it by doing a file search for your extensions identifier.
If you want a chrome reference, you can use:
chrome.extension.getURL('');
You can also provide something in the string and it will give you the path that you would need to reference the file contained in your app.
Example:
chrome.extension.getURL('index.html');
Returns:
"chrome-extension://gbchcmhmhahfdphkhkmpfmihenigjmpp/index.html"

Related

how can i host a json file on artifactory, can artifcatory be used as a webserver

I want to host a json file on artifactory repo.
Currently if i go to the link for the file it directly downloads.
But i want it to be shown as a file like a webserver.
Is that possible in artifactory ?
Can it work as a webserver for hosting single files ?
In order to achieve your use case, you need to enable content browsing option in your Artifcatory repository. You can find the details here:
Please be aware this may not work for all the file types(for json it should) as it's based on the mime types configured for the Artifactory application.
You can view any file or artifact from the Artifactory UI (tree browsing) or with native list browsing.
See more information about file browsing here and here.

Ship file with flatpak

I have a json file with some data that I want to ship with my application.
I want to include it on the folder /app/share/<app-name>/data/<file>.json.
I have researched, looked on the flatpak manifest documentation and the manifest of other applications, but I saw no mention to this option.
So, how would be the proper way of adding this file on the manifest?
You can do this by adding this file as part of the "sources" field in your module, and then installing it.
An example of this in the Flathub repo for Spotify. There, we definitely have a need for shipping separate files that make the integration into your DE seamless, as Spotify doesn't ship those. Concretely, let's look at the desktop launch file that is added:
The file can be found here: https://github.com/flathub/com.spotify.Client/blob/master/com.spotify.Client.desktop
You specify the relative path as a "file" source
Add the install command to the build-commands field of your module

Selenium ide to locate a file and store its path info from any computer

currently in my test scripts for automated file upload to browser, the paths are already defined in the value column
command type
target //input[#type='file']
value /Users/.../.../.../filename.extension
in such cases, this script is unable to run on other computers because the path would be different.
my question will be is
is there a way to locate the file in a general folder (for example file is downloaded and in the "download" folder), by using selenium ide can we get the path of the file (/Users/.../downloads/filename.extension)
store the path of the file with its extension into a notepad which i will be using it for multiple test of file uploads later on.
right now if my colleague needs to run the script from his computer, he have to manually change the value to his path.
You could use a suite file that contains a "setup" file to only change the file name in 1 place and the variable is shared across tests in the suite. You could also select an agreed up on place to store the files: c:\test_info\image.jpg.
Or you can make the file available by URL & not local, Unfortunately javascript prevents that for security: How to get the current file path in javascript
Unfortunately I can't think of any other good way unless you all have the same path in a home directory and could do something like ~/test_dir/photo.jpg

Chrome Extension manifest.json difference

I'm trying to create zip package for my chrome extension for chome webstore, and having difficulties to determine what kind manifest.json format that requires in the zip package.
my first attempt was to copy the manifest.json that in my extension (compiled to .crx file) into the zip package, so the content of zip package
manifest.json
myextension.crx
but this approach leads to a problem where background script cannot be loaded when try to install the extension in chrome.
my second attempt was to strip the manifest json and only leave some fields such name, description, and icon. It seems my second attempt was successful, as my extension can be installed.
Is my approach was correct? please advise.
The correct format of the manifest file is documented here. That having said, I suspect that the issue has nothing to do with your manifest file, but the structure of your zip file. When submitting a zip file, make sure that you zip the directory's content, not the directory itself.
E.g. the following structure is OK:
manifest.json
background.js
...
The following is not OK:
extension/manifest.json
extension/background.js
You've probably created the following situation, which is not OK, because it declares the background script as "background.js", while it's actually located at "extension/background.js":
manifest.js containing "background": {"scripts": ["background.js"] }
extension/background.js
Your second attempt probably worked because you had zipped the file in the correct way.
Actually you should upload a ZIP archive that contains just the root directory of your extension (nothing should be CRXed). According to the "Get Started" guide:
Create a ZIP archive of the directory that contains manifest.json and the icon. On Windows, you can do this by right-clicking myapp and choosing the menu item Send to > Compressed (zipped) folder. On Mac OS X, control-click myapp and choose Compress "myapp".
If you like to use the command line, you might enter this:
zip -r myapp.zip myapp
Note: The ZIP archive should not contain just the contents of the extension's root directory, but the root directory itself (with all its content, of course).
(BTW, I have no idea why your second attempt worked - according to the docs it shouldn't.)
UPDATE:
After trying it out myself, both approaches seem to work.
Bottom line, upload a ZIP archive with the content of your extension and not any CRXed stuff. Google will produce the CRX itself.

How can i get the path of file?

:image => StorageRoom::Image.new_with_filename(path)
I have to get the path of the image. So far i have specified the path manually and it worked and now i have put in heroku but it shows Load Error - No such file present.
How can i get the path value of the local system using browse button.
Your problem may not be related to path names, but to the fact that Heroku has a read-only file system. If you try to write files onto disk in a Heroku app, it simply doesn't work -- the file will not be saved.
The exception is the "temp" directory. You can save files there, but they are not guaranteed to persist for longer than the duration of a single request.
Is the file you are trying to open actually saved in your Git repo? If so, it will be on the disk in your Heroku app, and you should be able to open it.
To see what the filesystem layout looks like on your Heroku instance, you can create a controller method like:
render :inline => Dir['**/*'].inspect
File.expand_path
Reference : http://saaridev.blogspot.com/2006/11/ruby-finding-absolute-path-of-running.html
You don't need the full path. As far as file path in the client machine is concerned for file uploads, the path is irrelevant as it poses security risks for the user.
Most modern browsers don't send the file path for file uploads. You could get the path using Javascript or Flash but still I don't see the logic behind doing this.
When a user clicks on the submit button the browser should at least send you the file name with the file data together with a bunch of other information like the mime type. Your web server would either write the file to disk or process it in memory assuming you have near infinite memory resources. Look at the RFC 1867 for file uploads for more on this.