public class DXFile extends DXDataObject
Modifier and Type | Class and Description |
---|---|
static class |
DXFile.Builder
Builder class for creating a new
DXFile object. |
static class |
DXFile.Describe
Contains metadata for a file.
|
DXDataObject.DescribeOptions
cachedDescribe
Modifier and Type | Method and Description |
---|---|
DXFile |
close()
Closes the data object.
|
DXFile |
closeAndWait()
Closes the data object and waits until the close operation is complete.
|
DXFile.Describe |
describe()
Returns metadata about the data object.
|
DXFile.Describe |
describe(DXDataObject.DescribeOptions options)
Returns metadata about the data object, specifying which optional fields are to be returned
and what project to obtain project-specific metadata from.
|
byte[] |
downloadBytes()
Downloads the entire file into a byte array.
|
byte[] |
downloadBytes(long start,
long end)
Downloads the specified byte range of the file into a byte array.
|
void |
downloadToOutputStream(OutputStream os)
Downloads the entire file and writes the data to an OutputStream.
|
void |
downloadToOutputStream(OutputStream os,
long start,
long end)
Downloads the specified byte range of the file into an OutputStream.
|
DXFile.Describe |
getCachedDescribe()
Returns metadata about the data object, like
DXDataObject.describe() , but without
making an API call. |
InputStream |
getDownloadStream()
Returns a stream of the file's contents.
|
InputStream |
getDownloadStream(long start,
long end)
Returns a stream of the specified byte range of the file's contents.
|
static DXFile |
getInstance(String fileId)
Returns a
DXFile associated with an existing file. |
static DXFile |
getInstance(String fileId,
DXContainer project)
Returns a
DXFile associated with an existing file in a particular project or
container. |
static DXFile |
getInstanceWithEnvironment(String fileId,
DXContainer project,
DXEnvironment env)
Returns a
DXFile associated with an existing file in a particular project using the
specified environment. |
static DXFile |
getInstanceWithEnvironment(String fileId,
DXEnvironment env)
Returns a
DXFile associated with an existing file using the specified environment. |
OutputStream |
getUploadStream()
Returns an OutputStream that uploads any data written to it
|
static DXFile.Builder |
newFile()
Returns a Builder object for creating a new
DXFile . |
static DXFile.Builder |
newFileWithEnvironment(DXEnvironment env)
Returns a Builder object for creating a new
DXFile using the specified environment. |
void |
upload(byte[] data)
Uploads data from the specified byte array to the file.
|
void |
upload(InputStream data)
Uploads data from the specified stream to the file.
|
addTags, addTypes, checkCachedDescribeAvailable, checkDXLinkFormat, equals, getLinkAsJson, getProject, hashCode, listProjects, putAllProperties, putAllProperties, putProperty, removeProperty, removeTags, removeTypes, rename, setDetails, setVisibility
apiCallOnObject, apiCallOnObject, getId, toString
public static DXFile getInstance(String fileId)
DXFile
associated with an existing file.NullPointerException
- If fileId
is nullpublic static DXFile getInstance(String fileId, DXContainer project)
DXFile
associated with an existing file in a particular project or
container.NullPointerException
- If fileId
or container
is nullpublic static DXFile getInstanceWithEnvironment(String fileId, DXContainer project, DXEnvironment env)
DXFile
associated with an existing file in a particular project using the
specified environment.NullPointerException
- If fileId
or container
is nullpublic static DXFile getInstanceWithEnvironment(String fileId, DXEnvironment env)
DXFile
associated with an existing file using the specified environment.NullPointerException
- If fileId
is nullpublic static DXFile.Builder newFile()
DXFile
.public static DXFile.Builder newFileWithEnvironment(DXEnvironment env)
DXFile
using the specified environment.env
- environment to use to make API callspublic DXFile close()
DXDataObject
Returns the same object so you can chain calls.
close
in class DXDataObject
DXDataObject
public DXFile closeAndWait()
DXDataObject
Returns the same object so you can chain calls.
closeAndWait
in class DXDataObject
DXDataObject
public DXFile.Describe describe()
DXDataObject
The properties and details fields will not be returned, and any project-specific metadata
fields will be selected from an arbitrary project in which the requesting user has access to
this object. To change either of these aspects of this behavior, use
DXDataObject.describe(DescribeOptions)
instead.
describe
in class DXDataObject
Describe
containing the data object's metadata.public DXFile.Describe describe(DXDataObject.DescribeOptions options)
DXDataObject
describe
in class DXDataObject
options
- DescribeOptions
object specifying how the describe
request is
to be made.Describe
containing the data object's metadata.public byte[] downloadBytes() throws IOException
IOException
- if an error occurs while downloading the datapublic byte[] downloadBytes(long start, long end) throws IOException
start
- first byte of the range within the file to be downloaded. The start byte is
inclusive in the range, and 0 is indexed as the first byte in the file.end
- last byte of the range within the file to be downloaded. The end byte is exclusive
(not included in the range). An input of -1 specifies the end of the file.IOException
- if an error occurs while downloading the datapublic void downloadToOutputStream(OutputStream os) throws IOException
os
- output stream downloaded file contents are written intoIOException
public void downloadToOutputStream(OutputStream os, long start, long end) throws IOException
os
- output stream downloaded file contents are written intostart
- first byte of the range within the file to be downloaded. The start byte is
inclusive in the range, and 0 is indexed as the first byte in the file.end
- last byte of the range within the file to be downloaded. The end byte is exclusive
(not included in the range). An input of -1 specifies the end of the file.IOException
public DXFile.Describe getCachedDescribe()
DXDataObject
DXDataObject.describe()
, but without
making an API call.
This cached describe info is only available if this object appears in the result of a
DXSearch.findDataObjects()
call that specified
DXSearch.FindDataObjectsRequestBuilder.includeDescribeOutput()
, and the describe info
that is returned reflects the state of the object at the time that the search was performed.
getCachedDescribe
in class DXDataObject
Describe
containing the data object's metadatapublic InputStream getDownloadStream()
public InputStream getDownloadStream(long start, long end)
start
- first byte of the range within the file to be downloaded. The start byte is
inclusive in the range, and 0 is indexed as the first byte in the file.end
- last byte of the range within the file to be downloaded. The end byte is exclusive
(not included in the range). An input of -1 specifies the end of the file.public OutputStream getUploadStream()
The file must be in the "open" state. This method assumes exclusive access to the file: the file must have no parts uploaded before this call is made, and no other clients may upload data to the same file concurrently.
public void upload(byte[] data) throws IOException
The file must be in the "open" state. This method assumes exclusive access to the file: the file must have no parts uploaded before this call is made, and no other clients may upload data to the same file concurrently.
data
- data in bytes to be uploadedIOException
- if an error occurs while uploading the datapublic void upload(InputStream data) throws IOException
The file must be in the "open" state. This method assumes exclusive access to the file: the file must have no parts uploaded before this call is made, and no other clients may upload data to the same file concurrently.
data
- stream containing data to be uploadedIOException
- if an error occurs while uploading the dataCopyright © 2023. All Rights Reserved.