質問編集履歴
1
laravelのstorageに保存後、storageからpdfをdownloadさせるコード追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
|
24
24
|
|
25
|
-
```
|
25
|
+
```PHP
|
26
26
|
|
27
27
|
public function generatePdf()
|
28
28
|
|
@@ -60,7 +60,29 @@
|
|
60
60
|
|
61
61
|
- laravelのstorageに保存後、storageからpdfをdownloadさせる
|
62
62
|
|
63
|
+
```PHP
|
64
|
+
|
65
|
+
$disk = 'local'; // or 's3'
|
66
|
+
|
67
|
+
$storage = Storage::disk($disk);
|
68
|
+
|
69
|
+
$file_name = 'my_file.pdf';
|
70
|
+
|
71
|
+
$pdf_path = 'pdf/' . $file_name;
|
72
|
+
|
73
|
+
$file = $storage->get($pdf_path);
|
74
|
+
|
75
|
+
return response($file, 200)
|
76
|
+
|
77
|
+
->header('Content-Type', 'application/pdf')
|
78
|
+
|
79
|
+
->header('Content-Type', 'application/force-download')
|
80
|
+
|
81
|
+
->header('Content-Disposition', 'attachment; filename="' . $file_name . '"');
|
82
|
+
|
83
|
+
```
|
84
|
+
|
63
|
-
- header()の値を追加、変更
|
85
|
+
- header()の値を追加、変更(Content-length等)
|
64
86
|
|
65
87
|
|
66
88
|
|