public class DataFile extends DataObject
client, path
Constructor and Description |
---|
DataFile(HttpClient client,
java.lang.String dataUrl) |
Modifier and Type | Method and Description |
---|---|
void |
delete()
Deletes this file.
|
boolean |
exists()
Returns whether the file exists in the Data API
|
byte[] |
getBytes()
Gets the data for this file as as string
|
java.io.File |
getFile()
Gets the data for this file and saves it to a local temporary file
|
java.io.InputStream |
getInputStream()
Gets the data for this file as an InputStream
|
java.lang.String |
getString()
Gets the data for this file as as string
|
void |
put(byte[] data)
Upload raw data to this file as binary
|
void |
put(java.io.File file)
Upload new data to this file from an existing file.
|
void |
put(java.io.InputStream is)
Upload raw data to this file as an input stream
|
void |
put(java.lang.String data)
Upload string data to this file as text
|
getName, getParent, getUrl, toString
public DataFile(HttpClient client, java.lang.String dataUrl)
public boolean exists() throws APIException
exists
in class DataObject
APIException
- if there were any problems communicating with the DataAPIpublic java.io.File getFile() throws APIException, java.io.IOException
APIException
- if there were any problems communicating with the DataAPIjava.io.IOException
- if there were any problems consuming the response contentpublic java.io.InputStream getInputStream() throws APIException, java.io.IOException
APIException
- if there were any problems communicating with the Algorithmia APIjava.io.IOException
- if there were any problems consuming the response contentpublic java.lang.String getString() throws java.io.IOException
APIException
- if there were any problems communicating with the Algorithmia APIjava.io.IOException
- if there were any problems consuming the response contentpublic byte[] getBytes() throws java.io.IOException
APIException
- if there were any problems communicating with the Algorithmia APIjava.io.IOException
- if there were any problems consuming the response contentpublic void put(java.lang.String data) throws APIException
data
- the data to uploadAPIException
- if there were any problems communicating with the Algorithmia APIpublic void put(byte[] data) throws APIException
data
- the data to uploadAPIException
- if there were any problems communicating with the Algorithmia APIpublic void put(java.io.InputStream is) throws APIException
is
- the input stream of data to uploadAPIException
- if there were any problems communicating with the Algorithmia APIpublic void put(java.io.File file) throws APIException, java.io.FileNotFoundException
file
- the file to upload data fromAPIException
- if there were any problems communicating with the Algorithmia APIjava.io.FileNotFoundException
- if the specified file does not existpublic void delete() throws APIException
APIException
- if there were any problems communicating with the Algorithmia API