|
|
@@ -24,6 +24,7 @@ import { FilePathOnStoragePrefix, ResponseMode, type RespondOptions } from '~/se
|
|
|
import type { IAttachmentDocument } from '~/server/models/attachment';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
+import type { ConfigManager } from '../config-manager';
|
|
|
import { configManager } from '../config-manager';
|
|
|
|
|
|
import {
|
|
|
@@ -85,6 +86,13 @@ function getFilePathOnStorage(attachment: IAttachmentDocument) {
|
|
|
|
|
|
class AzureFileUploader extends AbstractFileUploader {
|
|
|
|
|
|
+ private readonly configManager: ConfigManager;
|
|
|
+
|
|
|
+ constructor(crowi: Crowi) {
|
|
|
+ super(crowi);
|
|
|
+ this.configManager = crowi.configManager as ConfigManager;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @inheritdoc
|
|
|
*/
|
|
|
@@ -132,7 +140,7 @@ class AzureFileUploader extends AbstractFileUploader {
|
|
|
const filePath = getFilePathOnStorage(attachment);
|
|
|
const containerClient = await getContainerClient();
|
|
|
const blockBlobClient: BlockBlobClient = containerClient.getBlockBlobClient(filePath);
|
|
|
- const contentHeaders = new ContentHeaders(attachment);
|
|
|
+ const contentHeaders = new ContentHeaders(this.configManager, attachment);
|
|
|
|
|
|
await blockBlobClient.uploadStream(readable, undefined, undefined, {
|
|
|
blobHTTPHeaders: {
|
|
|
@@ -210,7 +218,7 @@ class AzureFileUploader extends AbstractFileUploader {
|
|
|
const userDelegationKey = await blobServiceClient.getUserDelegationKey(startsOn, expiresOn);
|
|
|
|
|
|
const isDownload = opts?.download ?? false;
|
|
|
- const contentHeaders = new ContentHeaders(attachment, { inline: !isDownload });
|
|
|
+ const contentHeaders = new ContentHeaders(this.configManager, attachment, { inline: !isDownload });
|
|
|
|
|
|
// https://github.com/Azure/azure-sdk-for-js/blob/d4d55f73/sdk/storage/storage-blob/src/ContainerSASPermissions.ts#L24
|
|
|
// r:read, a:add, c:create, w:write, d:delete, l:list
|