Package cloud.metaapi.sdk.clients
Class HttpRequestOptions.FileStreamField
- java.lang.Object
-
- cloud.metaapi.sdk.clients.HttpRequestOptions.FileStreamField
-
- Enclosing class:
- HttpRequestOptions
public static class HttpRequestOptions.FileStreamField extends Object
File field wrapper for use in form data body. It is better to use this class for file fields because it explicitly gives opportunity to set files asFileorInputStream.
-
-
Constructor Summary
Constructors Constructor Description FileStreamField(File file)Constructs the file field wrapper fromFileobjectFileStreamField(InputStream stream, String fileName)Constructs the file field wrapper fromInputStreamand the file name
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringgetFileName()Returns the file name under which the file will be sent in requestInputStreamgetStream()ReturnsInputStreamwith contents of the filevoidsetFile(File file)Sets file fromFileobjectvoidsetFile(InputStream stream, String fileName)Sets file fromInputStreamobject
-
-
-
Constructor Detail
-
FileStreamField
public FileStreamField(File file) throws FileNotFoundException
Constructs the file field wrapper fromFileobject- Parameters:
file- file object which will be sent in request- Throws:
FileNotFoundException
-
FileStreamField
public FileStreamField(InputStream stream, String fileName)
Constructs the file field wrapper fromInputStreamand the file name- Parameters:
stream- input stream with contents of the filefileName- file name under which the file will be sent
-
-
Method Detail
-
setFile
public void setFile(File file) throws FileNotFoundException
Sets file fromFileobject- Parameters:
file- file object which will be sent in request- Throws:
FileNotFoundException
-
setFile
public void setFile(InputStream stream, String fileName)
Sets file fromInputStreamobject- Parameters:
stream- input stream with contents of the filefileName- file name under which the file will be sent
-
getStream
public InputStream getStream()
ReturnsInputStreamwith contents of the file- Returns:
- input stream
-
getFileName
public String getFileName()
Returns the file name under which the file will be sent in request- Returns:
- file name
-
-