Closed codeclout closed 1 year ago
This wouldn't be particularly difficult, but would require forking the project and replacing a good chunk of resolvers.js with something like this:
const URI = require('uri-js');
const fetch = require('node-fetch'); // you'll have to add node-fetch v2.x to package.json
// *** WARNING: Untested Code ***
// Create input stream from http location
const httpStream = async (location, callback) => {
const result = await fetch(location);
return await callback(result.body);
};
// Compute default stream location from ID
const defaultStreamLocation = (id) => {
return `http://imageserver/path/to/${id}.tif`;
};
// No metadata to read dimensions from; tell IIIF server to probe for size
const dimensionRetriever = async () => null;
Then you'd replace all remaining references to s3Stream
with httpStream
.
The idea is that the streamResolver
simply has to take the ID of an image and return a NodeJS ReadableStream
of the image contents.
It would certainly be easy enough to look at the location and return an S3 stream for s3://
URIs and an HTTP stream for http[s]://
URIs, and I might be inclined to support that in the future.
Whether you would also update your fork's deployment template to remove references to SourceBucket
or just give it dummy values that it will never use would be up to you.
@mbklein - Thank You!
Hello,
Is there an example in the serverless-iiif community that uses HTTP instead of S3 for image source retrieval? Our image sources are on-premises and transferring the sources to S3 is not an option for us at this time. If there is no concrete example, if you could share your thoughts on step-functions as a solution as well as any other solutions that would allow for retrieving sources via HTTP, that would be highly appreciated.
Thank You, Brian