• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/44

Click to flip

Use LEFT and RIGHT arrow keys to navigate between flashcards;

Use UP and DOWN arrow keys to flip the card;

H to show hint;

A reads text to speech;

44 Cards in this Set

  • Front
  • Back
How does a web application obtains access to the HTML5 Filesystem
A web application obtains access to the HTML5 Filesystem by requesting a LocalFileSystem object using a global method, window.requestFileSystem():
What is the syntax for window.requestFileSystem()
window.requestFileSystem(type, size, successCallback, opt_errorCallback)
Describe the type parameter of the window.requestFileSystem method.
Whether the storage should be persistent. Possible values are TEMPORARY or PERSISTENT.

Data stored using TEMPORARY can be removed at the browser’s discretion (for example if more space is needed).

PERSISTENT storage cannot cleared unless explicitly authorized by the user or the application.
Describe the size parameter of the window.requestFileSystem method.
An indicator of how much storage space, in bytes, the application expects to need.
Describe the successCallback parameter of the window.requestFileSystem method.
A callback function that is called when the user agent successfully provides a filesystem. Its argument is a FileSystem object.
Describe the opt_errorCallback parameter of the window.requestFileSystem method.
An optional callback function which is called when an error occurs, or the request for a filesystem is denied. Its argument is a FileError object.
What happens when you call window.requestFileSystem for the first time?
Calling window.requestFileSystem() for the first time creates a new sandboxed storage space for the app and origin that requested it
What is the restrictions on a filesystem
A filesystem is restricted to a single application and cannot access another application’s stored data.
What is the problem with using this method now.
This method is currently vendor prefixed as window.webkitRequestFile System.
Requesting a filesystem temporary storage
var onError = function(fs) {
console.log('There was an error');
};
var onFS = function(fs) {
console.log('Opened filesystem: ' + fs.name);
};
//window.requestFileSystem(window.TEMPORARY, //5*1024*1024 /*5MB*/, onFs, onError);
*******use vendor prefixed********
window.requestFileSystem(window.TEMPORARY, 5*1024*1024 /*5MB*/, onFs, onError);
If all goes well, the success callback (onFS) is called and passed a FileSystem object containing what two properties?
1. name
A unique name for the filesystem, assigned by the browser
2. root
A read-only DirectoryEntry representing the root of the filesystem
Howdo you get around the fact that applications are granted zero persistent quota by default
You need to request some persistent quota before opening the filesystem. That might mean simply wrapping the call to window.requestFileSystem() in the requestQuota() callback.
Show an example of requesting the file system with persistent storage
const SIZE = 5*1024*1024; /*5MB*/
const TYPE = PERSISTENT;
window.webkitStorageInfo.requestQuota(TYPE, SIZE, function(grantedBytes) {
window.requestFileSystem(TYPE, grantedBytes, onFs, onError);
}, function(e) {
console.log('Error', e);
});
How are files in a sandbox filesystem represented?
Files in the sandboxed filesystem are represented by the FileEntry interface.
What are the properties of the fileEntry interface?
1. isFile
2. isDirectory
3. name
4. fullPath
5. filesystem
Describe the isFile property of the FileEntry Interface.
Boolean. True if the entry is a file.
Describe the isDirectory property of the FileEntry Interface.
Boolean. True if the entry is a directory.
Describe the name property of the FileEntry Interface.
DOMString. The name of the entry, excluding the path leading to it.
Describe the fullPath property of the FileEntry Interface.
DOMString. The full absolute path from the root to the entry.
Describe the FileSystem property of the FileEntry Interface.
The filesystem on which the entry resides.
Describe the methods of the FileEntry Interface.
1. getMetadata
2. moveTo
3. copyTo
4. toURL
5. remove
6. getParent
7. createWriter
8. file
Describe getMetadata + syntax
getMetadata (successCallback, opt_errorCallback)
Look up metadata about this entry.
Describe moveTo + syntax
moveTo (parentDirEntry, opt_newName, opt_successCallback, opt_errorCallback)

Move an entry to a different location on the filesystem.
Describe copyTo + syntax
copyTo (parentDirEntry, opt_newName, opt_successCallback, opt_errorCallback)
Copies an entry to a different parent on the filesystem. Directory copies are always
recursive. It is an error to copy a directory inside itself or to copy it into its parent
if a new name is not provided.
Describe moveTo + syntax
toURL ();
Returns a filesystem: URL that can be used to identify this file. See
Describe toURL + syntax
remove (successCallback, opt_errorCallback)
Deletes a file or directory. It is an error to attempt to delete the root directory of a
filesystem or a directory that is not empty.
Describe getParent + syntax
getParent (successCallback, opt_errorCallback)

Return the parent DirectoryEntry containing this entry. If this entry is the root directory, its parent is itself.
Describe createWriter + syntax
createWriter (successCallback, opt_errorCallback)

Creates a new FileWriter which can be used to write content to this FileEntry.
Describe file + syntax
file (successCallback, opt_errorCallback)

Returns a File representing the FileEntry to the success callback.
How would you look up a file in a directory
To look up or create a file in a directory, call its getFile(), passing the name of the file to create.
Why would you want to only use asynchronus FileSystem IO
In order to avoid blocking UI actions while waiting on filesystem IO
What are the methods of the localFileSystem Object
1. requestFileSystem
2. resolveLocalFileSystemURL
Describe the method resolveLocalFileSystemURL of the localFileSystem Object.
Allows the user to look up the Entry for a file or directory referred to by a local URL.
What is the syntax for resolveLocalFileSystemURL
It has three parameter
1. the URL :
A URL referring to a local file in a filesystem accessable via this API.
2. successCallback:
A callback that is called to report the Entry to which the supplied URL refers.
3. errorCallback(optional):
A callback that is called when errors happen, or when the request to obtain the Entry is denied.
Describe the Directory Entry Interface
This interface represents a directory on a file system.
What are the methods of the DirectoryEntry interface
1. createReader
2. getDirectory
3. getFile
4. removeRecursively
Describe the createReader method of the DirectoryEntry interface.
Creates a new DirectoryReader to read Entries from this Directory.

No parameters.
Return type: DirectoryReader
Describe the getDirectory method of the DirectoryEntry interface.
Creates or looks up a directory.
parameters:
1. path (DomString)
2. options(Flags Object)
3. succesCallBack(entry Callback)
4. errorCallback(errorCAllback)
Describe the path parameter of the getDirectory method.
path is a required DomString that is either an absolute path or a relative path from this DirectoryEntry to the directory to be looked up or created. It is an error to attempt to create a directory whose immediate parent does not yet exist.
Describe the options parameter of the getDirectory method.
Is an optional flag object that sets two flgs create and exclusive to define behaviors if they are true or false the behaciors are as follows
1. If create and exclusive are both true and the path already exists, getDirectory must fail.
2. If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry.
3. If create is not true and the path doesn't exist, getDirectory must fail.
4. If create is not true and the path exists, but is a file, getDirectory must fail.
5. Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path.
Describe the getFile method of the DirectoryEntry interface.
Creates or looks up a file. Same signiture as getDirectory
parameters:
1. path (DomString)
2. options(Flags Object)
3. succesCallBack(entry Callback)
4. errorCallback(errorCAllback)
Describe the removeRecursively method of the DirectoryEntry interface.
Deletes a directory and all of its contents, if any. In the event of an error [e.g. trying to delete a directory that contains a file that cannot be removed], some of the contents of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem.
parameters:
successCallback
errorCallback
How do you use PERSISTENT storage with the FileSystem API
To use PERSISTENT storage with the FileSystem API, Chrome exposes a new API under window.webkitStorageInfo to request storage
How do you query an origins current quota usage and allocation?
There is also an API to query an origin's current quota usage and allocation: window.webkitStorageInfo.queryUsageAndQuota()