ファイルサイズ

このコミットが含まれているのは:
守矢諏訪子 2021-11-30 12:45:32 +09:00
コミット 64ccaa70f1
7個のファイルの変更37行の追加15行の削除

ファイルの表示

@ -105,7 +105,7 @@ class ChildrenController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
}
// ファイルサイズは10MiB以内
// ファイルサイズは5MiB以内又はnull
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesizecannull($value);
});
@ -393,7 +393,7 @@ class ChildrenController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
}
// ファイルサイズは10MiB以内
// ファイルサイズは5MiB以内
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesize($value);
});

ファイルの表示

@ -143,7 +143,7 @@ class FathersController extends Controller {
return $this->telsize($value);
});
// ファイルサイズは10MiB以内
// ファイルサイズは5MiB以内又はnull
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesizecannull($value);
});
@ -327,7 +327,7 @@ class FathersController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
}
// ファイルサイズは10MiB以内
// ファイルサイズは5MiB以内
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesize($value);
});

ファイルの表示

@ -27,7 +27,7 @@ class MeetingImagesController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
}
// ファイルサイズは10MiB以内
// ファイルサイズは各5MiB以内
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesizemulti($value);
});

ファイルの表示

@ -32,11 +32,17 @@ class MeetingsController extends Controller {
$r->image = json_decode($r->image);
}
// ファイルサイズは10MiB以内
// 画像サイズは各5MiB以内、PDFサイズは50MiB以内
//// 画像
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
return $this->imagesizemulti($value);
});
//// PDF
Validator::extend('pdf_size', function ($attribute, $value, $params, $validator) {
return $this->pdfsize($value);
});
// ミームタイプ
//// 画像
Validator::extend('image_meme', function ($attribute, $value, $params, $validator) {
@ -64,7 +70,7 @@ class MeetingsController extends Controller {
'title' => 'required|max:100',
'text' => 'required|max:2000',
'memo' => 'max:2000',
'pdf' => 'pdf_meme',
'pdf' => 'pdf_size|pdf_meme',
'image' => 'image_size|image_meme',
]);
@ -716,6 +722,11 @@ class MeetingsController extends Controller {
return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']];
}
// ファイルサイズは50MiB以内
Validator::extend('pdf_size', function ($attribute, $value, $params, $validator) {
return $this->pdfsize($value);
});
// ミームタイプ
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
return $this->pdfmeme($value);
@ -725,7 +736,7 @@ class MeetingsController extends Controller {
'title' => 'required|max:100',
'text' => 'required|max:2000',
'memo' => 'nullable|max:2000',
'pdf' => 'pdf_meme',
'pdf' => 'pdf_size_pdf_meme',
]);
if ($validate->fails()) {

ファイルの表示

@ -42,7 +42,7 @@ class Controller extends BaseController
public function imagesize ($value) {
try {
return strlen($value) < 10485760;
return strlen($value) < 5242880; // 5 MiB(メビバイト) / 5.24288 MB(メガバイト)
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
@ -123,7 +123,7 @@ class Controller extends BaseController
try {
$ok = true;
foreach (json_decode($value) as $v) {
if (strlen(base64_decode($v)) > 10485760) {
if (strlen(base64_decode($v)) > 5242880) { // 5 MiB(メビバイト) / 5.24288 MB(メガバイト)
$ok = false;
}
}
@ -134,6 +134,14 @@ class Controller extends BaseController
}
}
public function pdfsize ($value) {
try {
return strlen($value) < 52428800; // 50 MiB(メビバイト) / 52.4288 MB(メガバイト)
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
}
public function pdfmeme ($value) {
try {

ファイルの表示

@ -57,7 +57,7 @@ return [
'array' => 'The :attribute must have :value items or more.',
],
'image' => 'The :attribute must be an image.',
'image_size' => 'プロフィール画像は最大1M以内です。',
'image_size' => 'プロフィール画像は最大5M以内です。',
'image_meme' => 'ファイル形式はjpg/png/gifのみです。',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
@ -80,7 +80,7 @@ return [
],
'max' => [
'numeric' => 'The :attribute must not be greater than :max.',
'file' => 'プロフィール画像は最大1M以内です。',
'file' => 'プロフィール画像は最大5M以内です。',
'string' => '本文は最大 :attribute 文字以内です。',
'array' => 'The :attribute must not have more than :max items.',
],
@ -97,6 +97,8 @@ return [
'not_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.',
'password' => 'The password is incorrect.',
'pdf_size' => 'PDFは最大50M以内です。',
'pdf_meme' => 'ファイル形式はPDFのみです。',
'present' => 'The :attribute field must be present.',
'regex' => 'The :attribute format is invalid.',
'required' => ' :attribute は必須です。',

ファイルの表示

@ -57,7 +57,7 @@ return [
'array' => 'The :attribute must have :value items or more.',
],
'image' => 'The :attribute must be an image.',
'image_size' => 'プロフィール画像は最大1M以内です。',
'image_size' => 'プロフィール画像は最大5M以内です。',
'image_meme' => 'ファイル形式はjpg/png/gifのみです。',
'in' => 'The selected :attribute is invalid.',
'in_array' => 'The :attribute field does not exist in :other.',
@ -80,7 +80,7 @@ return [
],
'max' => [
'numeric' => ':attribute は最大 :max 数字以上です.',
'file' => 'プロフィール画像は最大1M以内です。',
'file' => 'プロフィール画像は最大5M以内です。',
'string' => ':attribute は最大 :max 文字以内です。',
'array' => ':attribute は最大 :max 配列要素以内です。',
],
@ -106,7 +106,8 @@ return [
'required_with_all' => 'The :attribute field is required when :values are present.',
'required_without' => 'The :attribute field is required when :values is not present.',
'required_without_all' => 'The :attribute field is required when none of :values are present.',
'pdf_meme' => 'ファイル形式はpdfのみです。',
'pdf_size' => 'PDFは最大50M以内です。',
'pdf_meme' => 'ファイル形式はPDFのみです。',
'prohibited' => 'The :attribute field is prohibited.',
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',