Allow file access not in Attachments table (#5876)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@@ -33,6 +33,34 @@ export default class AttachmentHelper {
|
||||
return `${keyPrefix}/${name}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a key into its constituent parts
|
||||
*
|
||||
* @param key The key to parse
|
||||
* @returns The constituent parts
|
||||
*/
|
||||
static parseKey(key: string): {
|
||||
bucket: string;
|
||||
userId: string;
|
||||
id: string;
|
||||
fileName: string | undefined;
|
||||
isPublicBucket: boolean;
|
||||
} {
|
||||
const parts = key.split("/");
|
||||
const bucket = parts[0];
|
||||
const userId = parts[1];
|
||||
const id = parts[2];
|
||||
const [fileName] = parts.length > 3 ? parts.slice(-1) : [];
|
||||
|
||||
return {
|
||||
bucket,
|
||||
userId,
|
||||
id,
|
||||
fileName,
|
||||
isPublicBucket: bucket === Buckets.avatars || bucket === Buckets.public,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ACL to use for a given attachment preset
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user