A matrix media proxy as cloudflare worker.
HOSTNAME: the hostname, for exampleexample.orgSERVERNAME: the servername, for exampleexample.org
Example in TypeScript, as seen in mxcId.ts:
function toBase64Url(value: string): string {
if (typeof btoa === 'function') {
const bytes = new TextEncoder().encode(value);
let binary = '';
for (const byte of bytes) {
binary += String.fromCodePoint(byte);
}
return btoa(binary).replaceAll('+', '-').replaceAll('/', '_').replaceAll(/=+$/g, '');
}
if (typeof Buffer !== 'undefined') {
return Buffer.from(value).toString('base64url');
}
throw new Error('No base64 encoder available in this runtime');
}
function toMatrixID(fname: string, prefix: string): string {
const base64 = toBase64Url(fname);
return prefix + base64;
}You can test it against the /_soliditas/adressconvert?remoteType=[remoteType]&remoteId=[remoteID] endpoint.
You need to generate a matrix id, using the algorithm as shown above.
Example:
- The giphy id is
yXPquATCb8kGk, this has been translated using thetoMatrixIDfunction, see above, togiphy_XPquATCb8kGk. - mxc:
mxc://example.org/giphy_XPquATCb8kGk - will return a redirect to
https://i.giphy.com/yXPquATCb8kGk.webp
You need to generate a matrix id, using the algorithm as shown above.
Example:
To-Do
You need to generate a matrix id, using the algorithm as shown above.
Example:
- The path on the klipy cdn is
ffd4ac143e6335ac68951b787d3c1902/e8/3a/5LM0jRpL.gif - mxc:
mxc://example.org/klipy_ZmZkNGFjMTQzZTYzMzVhYzY4OTUxYjc4N2QzYzE5MDIvZTgvM2EvNUxNMGpScEwuZ2lm - will return a redirect to
https://static.klipy.com/ii/ffd4ac143e6335ac68951b787d3c1902/e8/3a/5LM0jRpL.gif
This project is licensed under Apache 2.0, see LICENSE.