public abstract class FileRef extends Object
Operation
implementations which accept or return files.
When a FileRef instance is created by this SDK while referring to a temporary file location, calling any of the overloaded
saveAs
methods will delete the temporary file.
Modifier | Constructor and Description |
---|---|
protected |
FileRef() |
Modifier and Type | Method and Description |
---|---|
static FileRef |
createFromLocalFile(String localSource)
Creates a FileRef instance from a local file path where the media type can be inferred from the file extension.
|
static FileRef |
createFromLocalFile(String localSource,
String mediaType)
Creates a FileRef instance from a local file path with an explicitly specified media type.
|
static FileRef |
createFromStream(InputStream inputStream,
String mediaType)
Creates a FileRef instance from an input stream using the specified media type.
|
abstract void |
saveAs(OutputStream outputStream)
Writes the contents of this file to
outputStream . |
abstract void |
saveAs(String targetLocation)
Saves this file to the location specified by
targetLocation . |
public static FileRef createFromStream(InputStream inputStream, String mediaType)
The InputStream
is not read by this method but by consumers of file content such as
Operation.execute(ExecutionContext)
.
inputStream
- Stream representing the filemediaType
- Media type, to identify the file formatpublic static FileRef createFromLocalFile(String localSource, String mediaType)
If the media type can be inferred from the file extension, consider createFromLocalFile(String)
.
localSource
- Local file path, either absolute path or relative to classpathmediaType
- Media type to identify the local file formatpublic static FileRef createFromLocalFile(String localSource)
To specify the media type explicitly, use createFromLocalFile(String, String)
.
localSource
- Local file path, either absolute path or relative to classpathpublic abstract void saveAs(String targetLocation) throws IOException
targetLocation
.
If this FileRef instance refers to a temporary local file created by the SDK, that temporary file is deleted.
The directory mentioned in targetLocation
is created if it does not exist.
targetLocation
- Local file path, either an absolute path or relative to classpathFileAlreadyExistsException
- if the file already exists at the target locationIOException
- if an I/O error occurs while saving the fileUnsupportedOperationException
- if this FileRef instance does not represent an operation resultpublic abstract void saveAs(OutputStream outputStream) throws IOException
outputStream
.
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 outputStream
.
outputStream
- the destination output streamIOException
- if an I/O error occurs while writing to the output streamUnsupportedOperationException
- if this FileRef instance does not represent an operation resultCopyright © 2021 Adobe. All rights reserved.