com.rackspacecloud.client.cloudfiles
Class FilesObject

java.lang.Object
  extended by com.rackspacecloud.client.cloudfiles.FilesObject

public class FilesObject
extends java.lang.Object


Method Summary
 java.lang.String getLastModified()
           
 java.lang.String getMd5sum()
          Get's the MD5 Checksum for this object
 FilesObjectMetaData getMetaData()
          Return any metadata associated with this object
 java.lang.String getMimeType()
           
 java.lang.String getName()
           
 byte[] getObject()
          Download the contents of the object
 java.io.InputStream getObjectAsStream()
          Returns an inputStream with the contents of the object
 long getSize()
          Returns the size of the object, in bytes
 java.lang.String getSizeString()
          Returns the size as a human readable string, rounding to the nearest KB/MB/GB
 boolean isDirectory()
           
 void setLastModified(java.lang.String lastModified)
           
 void setMd5sum(java.lang.String md5sum)
           
 void setMimeType(java.lang.String mimeType)
           
 void setName(java.lang.String name)
          Set's the objects name (up to a maximum of 128 characters)
 void setSize(long size)
          Set the size of the object
static FilesObject uploadObject(java.io.File obj, java.lang.String mimeType, FilesContainer container)
           
static FilesObject uploadObject(java.io.File obj, java.lang.String mimeType, FilesContainer container, IFilesTransferCallback callback)
           
 long writeObjectToFile(java.io.File localFile)
          Download the object and write it to a local file
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getName

public java.lang.String getName()
Returns:
The object's name on the server

setName

public void setName(java.lang.String name)
Set's the objects name (up to a maximum of 128 characters)

Parameters:
name - The new name

getMimeType

public java.lang.String getMimeType()
                             throws org.apache.http.HttpException,
                                    java.io.IOException,
                                    FilesAuthorizationException,
                                    FilesInvalidNameException
Returns:
The MIME type of the object, pulled from the server
Throws:
org.apache.http.HttpException
java.io.IOException
FilesAuthorizationException
FilesInvalidNameException

setMimeType

public void setMimeType(java.lang.String mimeType)
Parameters:
mimeType - The new MIME type for this object

getMd5sum

public java.lang.String getMd5sum()
                           throws org.apache.http.HttpException,
                                  java.io.IOException,
                                  FilesAuthorizationException,
                                  FilesInvalidNameException
Get's the MD5 Checksum for this object

Returns:
The MD5 checksum, returned as a base 16 encoded string
Throws:
org.apache.http.HttpException
java.io.IOException
FilesAuthorizationException
FilesInvalidNameException

setMd5sum

public void setMd5sum(java.lang.String md5sum)
Parameters:
md5sum - The MD5 sum of the file (as a hex-encoded string)

getSize

public long getSize()
             throws org.apache.http.HttpException,
                    java.io.IOException,
                    FilesAuthorizationException,
                    FilesInvalidNameException
Returns the size of the object, in bytes

Returns:
The size of the object in bytes
Throws:
org.apache.http.HttpException
java.io.IOException
FilesAuthorizationException
FilesInvalidNameException

setSize

public void setSize(long size)
Set the size of the object

Parameters:
size - The size, in bytes

writeObjectToFile

public long writeObjectToFile(java.io.File localFile)
                       throws java.io.FileNotFoundException,
                              org.apache.http.HttpException,
                              java.io.IOException,
                              FilesAuthorizationException,
                              FilesInvalidNameException
Download the object and write it to a local file

Parameters:
localFile - The file
Returns:
The number of bytes written
Throws:
java.io.FileNotFoundException - Could not find the local file (does the path to it exist?)
org.apache.http.HttpException - There was an error communicating with the server
java.io.IOException - There was an I/O exception communicating with the server or writing the file.
FilesAuthorizationException
FilesInvalidNameException

getObjectAsStream

public java.io.InputStream getObjectAsStream()
                                      throws org.apache.http.HttpException,
                                             java.io.IOException,
                                             FilesAuthorizationException,
                                             FilesInvalidNameException
Returns an inputStream with the contents of the object

Returns:
An inputStream that will return the contents of the object
Throws:
org.apache.http.HttpException - There was an error communicating with the server
java.io.IOException - There was an I/O exception communicating with the server or writing the file.
FilesAuthorizationException
FilesInvalidNameException

getObject

public byte[] getObject()
                 throws org.apache.http.HttpException,
                        java.io.IOException,
                        FilesAuthorizationException,
                        FilesInvalidNameException,
                        FilesNotFoundException
Download the contents of the object

Returns:
The content of the object
Throws:
org.apache.http.HttpException - There was an error communicating with the server
java.io.IOException - There was an I/O exception communicating with the server or writing the file.
FilesAuthorizationException
FilesInvalidNameException
FilesNotFoundException

getMetaData

public FilesObjectMetaData getMetaData()
                                throws org.apache.http.HttpException,
                                       java.io.IOException,
                                       FilesAuthorizationException,
                                       FilesInvalidNameException
Return any metadata associated with this object

Returns:
The metadata
Throws:
org.apache.http.HttpException - There was an error communicating with the server
java.io.IOException - There was an I/O exception communicating with the server or writing the file.
FilesAuthorizationException
FilesInvalidNameException

uploadObject

public static FilesObject uploadObject(java.io.File obj,
                                       java.lang.String mimeType,
                                       FilesContainer container)
                                throws java.io.IOException,
                                       FilesException
Throws:
java.io.IOException
FilesException

uploadObject

public static FilesObject uploadObject(java.io.File obj,
                                       java.lang.String mimeType,
                                       FilesContainer container,
                                       IFilesTransferCallback callback)
                                throws java.io.IOException,
                                       FilesException
Throws:
java.io.IOException
FilesException

getSizeString

public java.lang.String getSizeString()
                               throws org.apache.http.HttpException,
                                      java.io.IOException,
                                      FilesAuthorizationException,
                                      FilesInvalidNameException
Returns the size as a human readable string, rounding to the nearest KB/MB/GB

Returns:
The size of the object as a human readable string.
Throws:
org.apache.http.HttpException - There was an error communicating with the server
java.io.IOException - There was an I/O exception communicating with the server or writing the file.
FilesAuthorizationException
FilesInvalidNameException

getLastModified

public java.lang.String getLastModified()
                                 throws org.apache.http.HttpException,
                                        java.io.IOException,
                                        FilesAuthorizationException,
                                        FilesInvalidNameException
Returns:
the lastModified
Throws:
org.apache.http.HttpException
java.io.IOException
FilesAuthorizationException
FilesInvalidNameException

setLastModified

public void setLastModified(java.lang.String lastModified)
Parameters:
lastModified - the lastModified to set

isDirectory

public boolean isDirectory()
Returns:
True if the "object" is really a directory.