Skip to content

Commit 3a9865a

Browse files
authored
fix #4308 【アップローダー】「.docx」「.xlsx」だと公開期間の指定が効いていない (#4310)
1 parent 821f6d7 commit 3a9865a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

plugins/bc-uploader/src/Controller/UploaderFilesController.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public function view_limited_file(UploaderFilesServiceInterface $service, string
6767
"sig" => "application/pgp-signature",
6868
"spl" => "application/futuresplash",
6969
"doc" => "application/msword",
70+
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
71+
"xls" => "application/vnd.ms-excel",
72+
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
73+
"ppt" => "application/vnd.ms-powerpoint",
74+
"pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
7075
"ai" => "application/postscript",
7176
"torrent" => "application/x-bittorrent",
7277
"dvi" => "application/x-dvi",
@@ -94,9 +99,16 @@ public function view_limited_file(UploaderFilesServiceInterface $service, string
9499
"asf" => "video/x-ms-asf",
95100
"wmv" => "video/x-ms-wmv"
96101
];
102+
103+
if (isset($contentsMaping[$ext])) {
104+
$contentType = $contentsMaping[$ext];
105+
} else {
106+
$contentType = 'application/octet-stream';
107+
}
108+
97109
$this->setResponse(
98110
$this->getResponse()
99-
->withHeader('Content-type', $contentsMaping[$ext])
111+
->withHeader('Content-Type', $contentType)
100112
->withBody(new Stream(WWW_ROOT . 'files' . DS . 'uploads' . DS . 'limited' . DS . $filename))
101113
);
102114
$this->disableAutoRender();

0 commit comments

Comments
 (0)