I've pushed some node application to CF and I want to access to the file system inside the application container ,I didn't found lot of docs about the application container (warden) file system and how should I access it from inside the application,in node js typically you should use the fs module...
You can use the file system to get to your application files the same way you would when running the application locally. You can use fs.
The file you want to read should be packaged with your application. If "foo.txt" is at the root of your application :
fs.readFile("foo.txt", "utf8", function(error, data) {
console.log(data);
});
Here is an example of using fs in a cloud foundry environment:
http://www.ibm.com/developerworks/cloud/library/cl-bluemix-nodejs-app/
Keep in mind, it is not a good idea to write data to the file system as it is ephemeral, and not shared across instances. Use a database service such as Mongo to save your data.
Related
I am developing a client-only ReactJS application (only for local usage) where I need to save and load images by filepaths (URL and local file system).
The paths are stored in the local storage and images from URLs can be used. Anyway, local images cannot since ReactJS is using the project directory and I cannot escape it.
Is there the possibility to open files with absolute path from the local file system or can I/do I have to upload it in the project directory?
Are you running this through a browser? If so Javascript on browsers does not yet have the ability to access local file systems. I haven't tried this but you could run Node locally and use ExpressJs for client-server communication.
As stated here:
you'll need two pieces:
A browser piece, which does the UI with the user.
A Node piece, which runs on the user's machine (and thus can access the file system) and which the browser piece uses to do the actual file operations.
Probably the easiest way for the pieces to interact would be HTTP, which you can trivially support using ExpressJS.
So for instance, if the user wants to delete a file:
User clicks something to say "delete this file"
Browser JavaScript sends the command to the Node process over HTTP via ajax
Node process does the deletion and reports success/failure
Browser JavaScript displays the result
A core requirement of my application is the ability to automatically deploy ArangoDB with all collections, graphs, data, and APIs. The HTTP API and the various wrappers have been sufficient for this so far, but I haven't been able to find an API for deploying Foxx services. Is there any way to create and deploy a Foxx service via RESTful API or through one of the wrappers? So far, the only way I know to create a Foxx service is through the web interface.
I found this question which leads me to believe it's possible, but I don't know how to specify the Git location of the Foxx service. Could you provide instructions for creating a Foxx service without the web UI and list the possible parameters?
To install a Foxx service via the REST API, you can use the endpoint HTTP PUT /_admin/foxx/install.
It will require a JSON body to be sent, with attributes named mount and appInfo. mount needs to contain the mountpoint (needs to start with a forward slash). appInfo is the application to be mounted. It can contain the filename as previously returned by the server from the call to /_api/upload, e.g.
{
"appInfo" : "uploads/tmp-30573-2010894858",
"mount" : "/my-mount-point"
}
install from remote URL
You can also install a Foxx service from a zip file available via HTTP(S) from an external server. You can include the username and password for HTTP Basic Auth as necessary:
{
"appInfo" : "https://user:password#example.com/my-service.zip",
"mount" : "/my-mount-point"
}
install from GitHub
You can also install a Foxx service from a GitHub repository, if the repository is public accessible, e.g.
{
"appInfo" : "git:arangodb-foxx/demo-hello-foxx:master",
"mount" : "/my-mount-point"
}
Behind the scenes, ArangoDB will translate the request into a regular URL for the zip bundle GitHub provides.
install from local file system
You can also install a Foxx service from a zip file or directory on the local filesystem:
{
"appInfo" : "/path/to/foxx-service.zip",
"mount" : "/my-mount-point"
}
This also works with directory, but ArangoDB will create a temporary zip file for you in this case.
Is it possible to use a local database file with html5 without using a server. I would like to create a small application that depends on information from a small database. I do not want to host a server just to pull information. Is it possible to create a database file and pull information from the local files ?
Depends on the following:
The type of application you want to build:
Normal website with some data being pulled from a local storage;
Special purpose hosted website / application with data generated by the user;
Special purpose local application with a dedicated platform (a particular browser) and with access to the browser's non-web API -- in order to access the browser's own persistent storage methods (file storage, SQLite etc.);
Special purpose local application with a dedicated environment -- in order to deploy the application with a local web server and database;
Available options:
Indexed DB
Web Storage
XML files used for storing data and XSLT stylesheets for translating the data into HTML;
Indexed DB and Web Storage ar available in some browsers but you need to make sure the targeted browsers have it. Their features aren't quite as complete and flexible as SQL RDBMSs but they may fit the bill if your application doesn't need all that flexibility.
XML files can contain the data you want to be shown to the user and they can be updated manually (not by the user) or dynamically (by a server script).
For dynamic updating the content of the XML is kept in JavaScript and manipulated / altered (using the XML DOM) and when the session is over the XML content is sent to the server to entirely replace the previous XML file. This works OK if the individual users have a file each and they never write to each other's files.
Reading local files:
Normal file access is prohibited (for security reasons) to all local (JavaScript) code, which means that "having" a file locally implies either downloading it from a known source (a server) or asking the user to offer access to a local file.
Asking the user to offer access to a local file which implies offering the user a "file input" -- like for uploads but without actually uploading the file.
After a file has been selected using FileAPI to read that file should be fairly simple.
This workflow would involve the user "giving" you the database on every page refresh -- but since it's a one page thing it would mean giving you the data on every session as long as your script does not refresh the page.
You can use localstorage but you can run a server from your own computer. You can use Wamp or Xampp. Which use Apache and mysql.
What i'm looking for is a little more robust than a cookie. I am making a web application for a friend that will be 1 page, and have a list of names on the page. The person wants to be able to add names to the list, however they do not want to use a web server. Just want the files locally on a computer so a folder called test-app , with index.html, and possibly a database file that can be stored in the web browser or a way to save information to the web browser for repeated use.
I need to store some data in my Blackberry application so I'm using files, I'm storing these files in the internal memory of the device, but if I uninstalled the application I need these files to be removed too.
Is there a way to store the files in the same path of the application package , or any other way to delete them if the application was uninstalled?
This is the path which I'm using:
try {
fileconn = (FileConnection) Connector.open("file:///store/home/user/data.txt");
}
What kind of data are you storing? If you can store the data in the app's PersistentStore instead, it will automatically be deleted when the app is uninstalled.
I'm trying to create a standalone HTML5 document that utilizes SQlite. I want to save the database in the same directory as the html file so that I can access the data on a usb stick from any computer. How do I specify where the database ought to be saved?
This is all I have so far:
var db = window.openDatabase("gtd", "", "GTD 3.0", 1024*1000);
From what I understand, the browser handles how and where the SQLite database is created or read from. Firefox places the SQLite db into a file inside the user's profile folder.
In Firefox the DOM storage data is stored in the webappsstore.sqlite file in the profile folder (there's also chromeappsstore.sqlite file used to store browser's own data, notably for the start page - about:home, but potentially for other internal pages with "about:" URLs).
(from https://developer.mozilla.org/en/DOM/Storage)