本文整理汇总了PHP中Illuminate\Support\Facades\Storage::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::size方法的具体用法?PHP Storage::size怎么用?PHP Storage::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Storage
的用法示例。
在下文中一共展示了Storage::size方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
/**
* Write a new file.
*
* @param string $path
* @param string $localPath
* @param Config $config Config object
*
* @return array|false false on failure file meta data on success
*/
public function write($path, $localPath, Config $config)
{
$object = $this->bucket->object($path);
$params = [];
$size = Storage::size($localPath);
if ($this->isSizeBiggerForMultiPart($size)) {
$params['multipart'] = true;
}
$object->write($localPath, $params);
}
示例2: zipAll
public function zipAll()
{
$files = TFFile::where('state', '=', 'downloaded')->get();
$imageCount = TFFile::where('state', '=', 'downloaded')->where('type', '=', 'image')->count();
$videoCount = TFFile::where('state', '=', 'downloaded')->where('type', '=', 'video')->count();
if ($videoCount == 0 && $imageCount == 0) {
Log::info('TFZipper : no file to be zipped.');
return;
}
$fileLocs = "";
$deleteLocs = [];
foreach ($files as $file) {
$deleteLocs[] = $file->location;
$fileLocs .= ' ' . storage_path('app/' . $file->location);
$file->state = 'zipped';
$file->save();
}
$zipName = Carbon::now()->toDateString() . '.zip';
$zipLocs = 'zip/' . $zipName;
$cmdPass = self::PASSWORD;
$cmdTarget = storage_path('app/' . $zipLocs);
$cmdLocs = $fileLocs;
$cmd = "";
$sys = php_uname('s');
if ($sys == 'Windows NT') {
$cmd = $this->rarCmd;
} else {
if ($sys == 'Linux') {
$cmd = $this->zipCmd;
}
}
$cmd = sprintf($cmd, $cmdPass, $cmdTarget, $cmdLocs);
if ($sys == 'Windows NT') {
$cmd = str_replace("/", "\\", $cmd);
}
$result = $this->runCmd($cmd);
if (false == $result) {
return;
}
$zip = new TFZip();
$zip->state = 'zipped';
$zip->error = '';
$zip->name = $zipName;
$zip->date = Carbon::now()->toDateString();
$zip->size = number_format(Storage::size($zipLocs) / 1024.0 / 1024.0, 2) . 'MB';
$zip->imageSize = $imageCount;
$zip->videoSize = $videoCount;
$zip->location = $zipLocs;
$zip->save();
Storage::delete($deleteLocs);
}
示例3: zipOneDay
public static function zipOneDay(Carbon $date)
{
$begin = $date->copy()->setTime(0, 0, 0);
$end = $date->copy()->setTime(23, 59, 59);
$deleteLocs = [];
$videoLocs = [];
$videos = Video::where('state', '=', 'downloaded')->where('updated_at', '>=', $begin->toDateTimeString())->where('updated_at', '<=', $end->toDateTimeString())->get();
foreach ($videos as $video) {
$deleteLocs[] = $video->location;
$videoLocs[] = storage_path('app/' . $video->location);
$video->state = 'zipped';
$video->save();
}
$imageLocs = [];
$images = Image::where('state', '=', 'downloaded')->where('updated_at', '>=', $begin->toDateTimeString())->where('updated_at', '<=', $end->toDateTimeString())->get();
foreach ($images as $image) {
$deleteLocs[] = $image->location;
$imageLocs[] = storage_path('app/' . $image->location);
$image->state = 'zipped';
$image->save();
}
$locs = array_merge($videoLocs, $imageLocs);
if (count($locs) == 0) {
Log::info('TumblrZip : no file to be ziped.');
return;
}
$zipName = $begin->toDateString() . '.zip';
$zipLocs = 'zips/' . $zipName;
$zippy = Zippy::load();
$zippy->create(storage_path('app/' . $zipLocs), $locs);
$zip = new Zip();
$zip->state = 'ziped';
$zip->error = '';
$zip->name = $zipName;
$zip->date = $begin->toDateString();
$zip->size = number_format(Storage::size($zipLocs) / 1024.0 / 1024.0, 2) . 'MB';
$zip->imageSize = count($imageLocs);
$zip->videoSize = count($videoLocs);
$zip->location = $zipLocs;
$zip->save();
Storage::delete($deleteLocs);
}
示例4: download
/**
* Download action
*
* @return mixed
*/
public function download()
{
$filename = config('data.filename');
return response(Storage::get($filename))->header('Content-Type', 'application/pdf')->header('Content-Length', Storage::size($filename));
}
示例5: getSize
public function getSize()
{
return $this->formatSize(Storage::size($this->code));
}