当前位置: 首页>>代码示例>>PHP>>正文


PHP Storage::size方法代码示例

本文整理汇总了PHP中Storage::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Storage::size方法的具体用法?PHP Storage::size怎么用?PHP Storage::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Storage的用法示例。


在下文中一共展示了Storage::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getStreamResponse

 private function getStreamResponse(Extra $extra, string $aspect = '16x9')
 {
     $size = \Storage::size($path = $this->getVideoPath($extra->id, $aspect));
     return response()->download($path, 'test123', ['Content-Type' => 'video/mp4']);
     $stream = fopen($path, "r");
     $type = 'video/mp4';
     $start = 0;
     $length = $size;
     $status = 200;
     $headers = ['Content-Type' => $type, 'Content-Length' => $size, 'Accept-Ranges' => 'bytes'];
     if (false !== ($range = request()->server('HTTP_RANGE', false))) {
         list($param, $range) = explode('=', $range);
         if (strtolower(trim($param)) !== 'bytes') {
             header('HTTP/1.1 400 Invalid Request');
             exit;
         }
         list($from, $to) = explode('-', $range);
         if ($from === '') {
             $end = $size - 1;
             $start = $end - intval($from);
         } elseif ($to === '') {
             $start = intval($from);
             $end = $size - 1;
         } else {
             $start = intval($from);
             $end = intval($to);
         }
         $length = $end - $start + 1;
         $status = 206;
         $headers['Content-Range'] = sprintf('bytes %d-%d/%d', $start, $end, $size);
     }
     return response()->stream(function () use($stream, $start, $length) {
         fseek($stream, $start, SEEK_SET);
         echo fread($stream, $length);
         fclose($stream);
     }, $status, $headers);
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:37,代码来源:MediaControllerNew.php

示例2:

            <th>ACCION</th>
        </tr>
        </thead>
        <tbody>
        @foreach($medios as $medio)

            <tr>
                <td>{{ $medio->id }}</td>
                <td>
                  <a href="/medios/{{ $medio->nombre}}" target="newwindow"
                    data-toggle="tooltip" data-placement="right"
                    title="PRESIONE CLICK PARA VER O DESCARGAR SEGUN SEA EL TIPO DE ARCHIVO">
                    <?php 
if (Storage::exists($medio->nombre)) {
    $nombre = $medio->nombre;
    $tamanio = Storage::size($medio->nombre);
    $creado = $medio->created_at;
    $tipo = $medio->tipo;
    if ($tipo == 'jpg' || $tipo == 'png' || $tipo == 'jpeg' || $tipo == 'gif') {
        ?>
<img class="img_click" src="/medios/{{ $medio->nombre}}"><?php 
    } else {
        if ($tipo == 'pdf') {
            ?>
<img class="img_click" src="/img/pdf.png"><?php 
        } else {
            if ($tipo == 'doc' || $tipo == 'dot' || $tipo == 'docx') {
                ?>
<img class="img_click" src="/img/m_word.png"><?php 
            } else {
                if ($tipo == 'xls' || $tipo == 'xlm' || $tipo == 'xlt' || $tipo == 'xlv' || $tipo == 'ods') {
开发者ID:3JSoluciones,项目名称:cafesdelhuila,代码行数:31,代码来源:listado.blade.php

示例3: streamVideo

 /**
  * to stream videos online
  */
 public function streamVideo()
 {
     $size = \Storage::size($this->getRealPath($this->filepath));
     $file = \Storage::get($this->getRealPath($this->filepath));
     $stream = fopen($this->getRealPath($this->filepath), "r");
     $type = 'video/mp4';
     $start = 0;
     $length = $size;
     $status = 200;
     $headers = ['Content-Type' => $type, 'Content-Length' => $size, 'Accept-Ranges' => 'bytes'];
     if (false !== ($range = request()->server('HTTP_RANGE', false))) {
         list($param, $range) = explode('=', $range);
         if (strtolower(trim($param)) !== 'bytes') {
             header('HTTP/1.1 400 Invalid Request');
             exit;
         }
         list($from, $to) = explode('-', $range);
         if ($from === '') {
             $end = $size - 1;
             $start = $end - intval($from);
         } elseif ($to === '') {
             $start = intval($from);
             $end = $size - 1;
         } else {
             $start = intval($from);
             $end = intval($to);
         }
         $length = $end - $start + 1;
         $status = 206;
         $headers['Content-Range'] = sprintf('bytes %d-%d/%d', $start, $end, $size);
     }
     return response()->stream(function () use($stream, $start, $length) {
         fseek($stream, $start, SEEK_SET);
         echo fread($stream, $length);
         fclose($stream);
     }, $status, $headers);
     //        dd($this->getRealPath($this->filepath));
     //        $video = new StreamVideoJob($this->getRealPath($this->filepath));
     //        $video->start();
     //        exit;
 }
开发者ID:SkysoulDesign,项目名称:mirage.dev,代码行数:44,代码来源:MediaController.php


注:本文中的Storage::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。