Methods
(static) createFromLocalFile(filePathnon-null, mediaTypeopt) → {FileRef}
Creates a FileRef instance from a local file path. If no media type is provided, it will be inferred from the file extension.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string | Local file path, either absolute path or relative to the working directory. |
|
mediaType |
string |
<optional> |
Media type to identify the local file format. |
Returns:
A FileRef instance.
- Type
- FileRef
(static) createFromStream(inputStreamnon-null, mediaTypenon-null) → {FileRef}
Creates a FileRef instance from a readable stream using the specified media type.
The stream is not read by this method but by consumers of file content i.e. the execute method of an operation such as ExtractPDFOperation#execute .
Parameters:
Name | Type | Description |
---|---|---|
inputStream |
stream.Readable | Readable Stream representing the file. |
mediaType |
string | Media type to identify the file format. |
Returns:
A FileRef instance.
- Type
- FileRef
saveAsFile(destinationFilePathnon-null) → {Promise.<void>}
Saves this file to the location specified by destinationFilePath
.
If this FileRef instance refers to a temporary local file created by the SDK, that temporary file is deleted.
The directories mentioned in the specified argument are created if they do not exist.
Parameters:
Name | Type | Description |
---|---|---|
destinationFilePath |
string | Local file path, either an absolute path or relative to the working directory. |
Throws:
-
-
If the file already exists.
- Type
- Error
-
-
-
If this FileRef instance does not represent an operation result.
- Type
- Error
-
Returns:
A Promise
that resolves when the fileRef instance has been moved to the specified location.
- Type
- Promise.<void>
writeToStream(writableStreamnon-null)
Writes the contents of this file to writableStream
.
If this FileRef instance refers to a temporary local file created by the SDK, that temporary file is deleted.
Note: This method does not close the writableStream
.
Parameters:
Name | Type | Description |
---|---|---|
writableStream |
stream.Writable | The destination writable stream. |
Throws:
-
If this FileRef instance does not represent an operation result.
- Type
- Error