Open
Description
I'm encountering an issue while using the GetObjectResponse object from the OCI Object Storage library. When trying to use the .pipe() method on the value property of the GetObjectResponse, I receive the following error:
TypeError: imageStream.pipe is not a function
Expected Behavior:
The .pipe() method should work as expected on the value property, allowing the stream content to be piped to a response object.
Actual Behavior:
Encountering the "TypeError: imageStreamValue.pipe is not a function" error when attempting to use .pipe() on the value property.
#oci-object-storage-service.ts
async getImageAsStream(folderName: string, imageName: string): Promise<GetObjectResponse | null> {
try {
const authenticationProvider = this.createAuthenticationProvider();
const objectStorageClient = new ObjectStorageClient({
authenticationDetailsProvider: authenticationProvider,
});
const objectName = folderName + '/' + imageName;
const getObjectRequest = {
namespaceName: process.env.OCI_NAMESPACE + '',
bucketName: process.env.OCI_BUCKET_NAME + '',
objectName: objectName,
};
const getObjectResponse = await objectStorageClient.getObject(getObjectRequest);
if (getObjectResponse) {
return getObjectResponse;
}
return null;
} catch (error) {
console.error('Error fetching image stream:', error);
return null;
}
}
Below is my controller:-
#image.controller.ts
@get('/image-stream/{folderName}/{imageName}')
async getImageStream(
@param.path.string('folderName') folderName: string,
@param.path.string('imageName') imageName: string,
@inject(RestBindings.Http.RESPONSE) response: Response,
): Promise<any> {
const ociResponse = await this.cloudStorageService.getImageAsStream(folderName, imageName);
if (ociResponse) {
imageStream = ociResponse.value;
response.setHeader('Content-Type', 'image/png');
imageStream.pipe(response);
} else {
response.status(404).send('Image not found');
}
}
}
Metadata
Metadata
Assignees
Labels
No labels