I want to convert a FileInputStream
to a S3ObjectInputStream
.
This is my current code:
InputStream is = new FileInputStream(file);
S3ObjectInputStream sObject = (S3ObjectInputStream)is;
However, it's giving the error:
java.io.FileInputStream cannot be cast to com.amazonaws.services.s3.model.S3ObjectInputStream
Use the below constructor to convert an InputStream
to a S3ObjectInputStream
:
var s3ObjectInputStream = new S3ObjectInputStream(inputStream, null);
You can safely use null
for the 2nd argument in the constructor (HttpRequestBase
) as the abort
method which uses it, isn't available in the cast InputStream
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With