Struggling with downloadObject() to fetch S3 binary file
I am strugging with downloadObject() to fetch a PDF file from an S3 bucket.
s3Svc = getCloudService("iamCreds", "s3config")
bucket = s3Svc.bucket("mybucket", false)
data = bucket.downloadOjbect({ key="myPdfFile.pdf" })The Adobe documentation states that "key" is the only required parameter but my server, CF2021u13, throws an error and states, "Field type is mandatory and must have a non-null value."
The docs fail me again because they don't tell us what the acceptable values are other than "json". Why is Adobe documentation so sparse?
I tried the following:
data = bucket.downloadOjbect({ key="myPdfFile.pdf", type="json" })This fetches the file content from s3 but then fails with a "JSON parsing failure at character 1" because it tries to parse the binary PDF content as JSON. Adding useCustomSerializer=true|false doesn't make change anything.
I tried changing the value of 'type' to "binary", "object", "struct", "pdf", and "string" but they all give me the error, "xxx is not supported by ColdFusion for serialization or deserialization".
All I want to do is download a binary file from s3 and store it in an in-memory variable. I do not want to write it to disk with downloadToFile(). Surely somebody has figured this out?
I haven't been able to find a single example of downloadObject() which downloads a binary file. Every example I have found is working with a text file.
