Show / Hide Table of Contents

Class FileRef

This class represents either a local file or a URL-based web page. It is typically used by IOperation implementations which accept or return files.

If a FileRef instance is created by this SDK and it refers to a temporary file location, calling any of the overloaded saveAs methods will delete the temporary file.

Inheritance
System.Object
FileRef
Namespace: Adobe.DocumentCloud.Services.io
Assembly: Adobe.DocumentCloud.Services.Doc.dll
Syntax
public abstract class FileRef

Methods

CreateFromLocalFile(String)

Creates a FileRef instance from a local file path where the media type can be inferred from the file extension.

To specify the media type explicitly, use CreateFromLocalFile(String, String).

Declaration
public static FileRef CreateFromLocalFile(string localSource)
Parameters
Type Name Description
System.String localSource

Local file path

Returns
Type Description
FileRef

a FileRef instance

CreateFromLocalFile(String, String)

Creates a FileRef instance from a local file path with an explicitly specified media type.

If the media type can be inferred from the file extension, consider CreateFromLocalFile(String).

Declaration
public static FileRef CreateFromLocalFile(string localSource, string mediaType)
Parameters
Type Name Description
System.String localSource

Local file path

System.String mediaType

Media type to identify the local file format

Returns
Type Description
FileRef

a FileRef instance

CreateFromStream(Stream, String)

Creates a FileRef instance from an input stream using the specified media type.

The Stream is not read by this method but by consumers of file content such as Execute(ClientContext)

Declaration
public static FileRef CreateFromStream(Stream inputStream, string mediaType)
Parameters
Type Name Description
System.IO.Stream inputStream

Stream representing the file

System.String mediaType

Media type, to identify the file format

Returns
Type Description
FileRef

a FileRef instance

CreateFromUrl(Uri, String)

Creates a FileRef instance from a URL. Currently, this must only be used for specifying an HTML web page.

Declaration
public static FileRef CreateFromUrl(Uri url, string mediaType)
Parameters
Type Name Description
System.Uri url

URL of a web page

System.String mediaType

Media type of the contents at the URL; must be "text/html"

Returns
Type Description
FileRef

a FileRef instance

SaveAs(Stream)

Writes the contents of this file to 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.

Declaration
public abstract void SaveAs(Stream outputStream)
Parameters
Type Name Description
System.IO.Stream outputStream

the destination output stream

Exceptions
Type Condition
System.IO.IOException

An I/O error occurred.

System.ArgumentException

Invalid sourceFile name

System.UnauthorizedAccessException

Does not have the required permission to delete the source file

System.InvalidOperationException

thrown when method SaveAs called on non operation results

SaveAs(String)

Saves this file to the location specified by 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.

Declaration
public abstract void SaveAs(string targetLocation)
Parameters
Type Name Description
System.String targetLocation

Local file path

Exceptions
Type Condition
System.IO.IOException

File already exists in the target location

System.ArgumentException

Invalid sourceFile or destination file name

System.UnauthorizedAccessException

Does not have the required permission to move the file to a specified location

System.InvalidOperationException

thrown when method SaveAs called on non operation results

Back to top Copyright © 2019 Adobe. All rights reserved.