r2 modify
This commit is contained in:
@@ -1551,7 +1551,6 @@ export class InstructorService {
|
||||
key: storedFileName,
|
||||
body: file.buffer,
|
||||
contentType: file.mimetype,
|
||||
fileName: originalFileName,
|
||||
});
|
||||
} else {
|
||||
await mkdir(COURSE_REFERENCE_UPLOAD_ROOT, { recursive: true });
|
||||
|
||||
@@ -6,7 +6,6 @@ type UploadPublicFileInput = {
|
||||
key: string;
|
||||
body: Buffer;
|
||||
contentType?: string | null;
|
||||
fileName?: string | null;
|
||||
};
|
||||
|
||||
@Injectable()
|
||||
@@ -53,7 +52,6 @@ export class R2PublicFileService {
|
||||
Body: input.body,
|
||||
ContentLength: input.body.length,
|
||||
ContentType: input.contentType ?? 'application/octet-stream',
|
||||
ContentDisposition: input.fileName ? contentDispositionForFile(input.fileName) : undefined,
|
||||
}));
|
||||
|
||||
return this.publicUrl(input.key);
|
||||
@@ -120,8 +118,3 @@ export class R2PublicFileService {
|
||||
function encodeObjectKey(key: string) {
|
||||
return key.split('/').map(encodeURIComponent).join('/');
|
||||
}
|
||||
|
||||
function contentDispositionForFile(fileName: string) {
|
||||
const fallbackName = fileName.replace(/[\\\"\r\n]/g, '_');
|
||||
return `attachment; filename="${fallbackName}"; filename*=UTF-8''${encodeURIComponent(fileName)}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user