store/File

Source:

Methods

get(writableStream) → {Promise}

Source:
Parameters:
Name Type Description
writableStream

a writable stream, e.g. in nodejs it can be created via fs.createWriteStream('./output');

Returns:

which format the resource is returned in the promise (string, json or xml) depends on what is specified in the mimetype. Xml is only returned in a browser environment, if not in a browser a string is returned.

Type
Promise

getJSON() → {Promise.<Object>}

Source:
Returns:

ignores what is specified in the mimetype and returns the resource as a javascript object in the promise.

Type
Promise.<Object>

getText() → {Promise.<String>}

Source:
Returns:

ignores what is specified in the mimetype and returns the resource as a string in the promise.

Type
Promise.<String>

getXML() → {Promise}

Source:
Returns:

ignores what is specified in the mimetype and returns the resource in the promise as a XML Document or a string (depending on if you are in browser or not).

Type
Promise

(async) put(data, format) → {Promise}

Description:
  • Pushes data to the server for this resource.

Source:
Parameters:
Name Type Default Description
data string

to be stored as a file.

format string application/json

the format of the data as a mimetype.

Returns:
Type
Promise

(async) putFile(data, format) → {Promise}

Description:
  • Pushes a file to the server for this resource. In a browser environment a file is represented via an input tag which references the file to be uploaded via its value attribute. E.g.:

      <input type="file" name="uploadFile"/>
    

    During the uploading process the input tag will be moved temporarily in the DOM tree, it will be restored to its original position afterwards (both upon success and failure).

    In a nodejs environments the file is leveraged as a stream, i.e.: res.putFile(fs.createReadStream('file.txt'));

Source:
To Do:
  • fix-if-modified-since
Parameters:
Name Type Description
data node | fileHandle

input tag or file handle that corresponds to a file.

format string

indicates the mimetype of the data

Returns:
Type
Promise

putJSON(obj) → {Promise}

Description:
  • Pushes JSON content to the server for this resource.

Source:
Parameters:
Name Type Description
obj Object

to be stored as a json object, format will be set to application/json.

Returns:
Type
Promise

putText(text) → {Promise}

Description:
  • Pushes text content to the server for this resource.

Source:
Parameters:
Name Type Description
text string

to be stored as a file, format will be set to text/plain.

Returns:
Type
Promise

putXML(xml) → {Promise}

Description:
  • Pushes xml content to the server for this resource.

Source:
To Do:
  • not finished or tested
Parameters:
Name Type Description
xml string | Document

to be stored as a xml object, format will be set to application/json.

Returns:
Type
Promise