|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.AbstractInputStreamContent
com.google.api.client.http.FileContent
public final class FileContent
Concrete implementation of AbstractInputStreamContent
that generates repeatable input
streams based on the contents of a file.
Sample use:
private static void setRequestJpegContent(HttpRequest request, File jpegFile) {
request.setContent(new FileContent("image/jpeg", jpegFile));
}
Implementation is not thread-safe.
Constructor Summary | |
---|---|
FileContent(String type,
File file)
|
Method Summary | |
---|---|
File |
getFile()
Returns the file. |
protected InputStream |
getInputStream()
Return an input stream for the specific implementation type of AbstractInputStreamContent . |
long |
getLength()
Returns the content length or less than zero if not known. |
boolean |
retrySupported()
Returns whether or not retry is supported on this content type. |
FileContent |
setEncoding(String encoding)
Sets the content encoding (for example "gzip" ) or null for none. |
FileContent |
setType(String type)
Sets the content type or null for none. |
Methods inherited from class com.google.api.client.http.AbstractInputStreamContent |
---|
copy, getEncoding, getType, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileContent(String type, File file)
type
- Content type or null
for nonefile
- fileMethod Detail |
---|
public long getLength()
HttpContent
public boolean retrySupported()
HttpContent
protected InputStream getInputStream() throws FileNotFoundException
AbstractInputStreamContent
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.
getInputStream
in class AbstractInputStreamContent
FileNotFoundException
public File getFile()
public FileContent setEncoding(String encoding)
AbstractInputStreamContent
"gzip"
) or null
for none.
setEncoding
in class AbstractInputStreamContent
public FileContent setType(String type)
AbstractInputStreamContent
null
for none.
setType
in class AbstractInputStreamContent
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |