com.google.api.client.http
Class FileContent
java.lang.Object
com.google.api.client.http.AbstractInputStreamContent
com.google.api.client.http.FileContent
- All Implemented Interfaces:
- HttpContent
public final class FileContent
- extends AbstractInputStreamContent
Concrete implementation of AbstractInputStreamContent that generates repeatable input
streams based on the contents of a file.
The AbstractInputStreamContent.type fields is required.
Sample use:
private static void setRequestJpegContent(HttpRequest request, File jpegFile) {
FileContent content = new FileContent(jpegFile);
content.type = "image/jpeg";
request.content = content;
}
- Since:
- 1.4
- Author:
- moshenko@google.com (Jacob Moshenko)
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileContent
public FileContent(File file)
- Parameters:
file - File handle which will be used to create input streams.
getLength
public long getLength()
- Description copied from interface:
HttpContent
- Returns the content length or less than zero if not known.
retrySupported
public boolean retrySupported()
- Description copied from interface:
HttpContent
- Returns whether or not retry is supported on this content type. This is a backward incompatible
change that affects versions prior to 1.4.
getInputStream
protected InputStream getInputStream()
throws FileNotFoundException
- Description copied from class:
AbstractInputStreamContent
- Return an input stream for the specific implementation type of
AbstractInputStreamContent. If the specific implementation will return true for
HttpContent.retrySupported() this should be a factory function which will create a new
InputStream from the source data whenever invoked.
- Specified by:
getInputStream in class AbstractInputStreamContent
- Throws:
FileNotFoundException
Copyright © 2010-2011 Google. All Rights Reserved.