0

Following is a part of code I have written:

S3Object obj1 = null; obj1 = s3client.getObject("bucketname", "file.yml"); 
S3ObjectInputStream instream = obj1.getObjectContent ();

I get the following error while deploying my code to openfaas:

error: incompatible types: InputStream cannot be converted to S3ObjectInputStream S3ObjectInputStream instream = obj1.getObjectContent ();

Yash
  • 11,486
  • 4
  • 19
  • 35
Abcd
  • 1
  • Can you add a little more context about what you are trying to do? A code snippet? – Yash Oct 02 '19 at 11:02
  • have you read the error message? It's pretty straightforward – Stultuske Oct 02 '19 at 11:04
  • S3Object obj1 = null; obj1 = s3client.getObject("bucketname", "file.yml"); S3ObjectInputStream instream = obj1.getObjectContent (); @Yash – Abcd Oct 02 '19 at 11:21
  • 1
    That is a compilation error. It is highly unlikely that you are getting while **deploying** your code. – Stephen C Oct 02 '19 at 11:48
  • I have made the snippet provided by you as part of the problem. But as @Stephen C pointed out, you are highly unlikely to run into this problem only while deploying. Can you confirm if you are able to run this locally? – Yash Oct 02 '19 at 11:53
  • yes it is a compilation error. – Abcd Oct 03 '19 at 03:27

1 Answers1

0

So I don't know a lot about AWS (yet), but reading the specification for the S3Client, your declaration is possibly incorrect, as there does not seem to be an implementation of S3Client.getObject() that supports two String inputs. Instead it's looking for a GetObjectRequest (namely S3Client.getObject(GetObjectRequest getObjectRequest))

So your implementation may have to be something as follows:

S3Object s3Object = s3client.getObject(new GetObjectRequest(bucket, key))

Here's an example : Amazon.S3.Model.GetObjectRequest

Ambro-r
  • 919
  • 1
  • 4
  • 14