小编Ram*_* Gh的帖子

提出请求并处理可​​恢复上传的响应:Google Drive api [php]

我正在使用PHP客户端库(Beta)来使用谷歌驱动器api,到目前为止,我可以在chuncks中授权和上传文件.根据文档,应该采取这三个步骤来上传文件:

  • 开始一个可恢复的会话.
  • 保存可恢复的会话URI.
  • 上传文件.

我认为客户端库处理.同样,根据文档,如果我想显示进度或恢复中断上传,或者为了处理错误,我需要捕获响应并且还能够发送如下请求:

> PUT {session_uri} HTTP/1.1 Content-Length: 0 Content-Range: bytes
> */2000000
Run Code Online (Sandbox Code Playgroud)

但我不知道我应该如何提出这样的请求,我在哪里可以得到响应,我用来上传的php代码,就像任何其他PHP代码一样,只有在完成执行时返回值,即上传时已经完成了.这是我用来上传文件的功能(Resumable):

function uploadFile($service,$client,$filetoUpload,$parentId){
    $file = new Google_Service_Drive_DriveFile();
    $file->title = $filetoUpload['name'];
    $chunkSizeBytes = 1 * 1024 * 1024;

    // Set the parent folder.
      if ($parentId != null) {
        $parent = new Google_Service_Drive_ParentReference();
        $parent->setId($parentId);
        $file->setParents(array($parent));
      }

    // Call the API with the media upload, defer so it doesn't immediately return.
    $client->setDefer(true);
    $request = $service->files->insert($file);

    // Create a media file upload to represent our …
Run Code Online (Sandbox Code Playgroud)

php file-upload google-drive-api

13
推荐指数
1
解决办法
1228
查看次数

Chrome的html5视频问题

我想在我的网页上使用html5视频,这里是代码:

<video id="vid" width="100%" autoplay loop>
  <source src="video/video.webm" type="video/webm">
  <source src="video/video.mp4" type="video/mp4">

Your browser does not support the video tag.
</video>
Run Code Online (Sandbox Code Playgroud)

问题是,当我使用webm作为视频源时:

<source src="video/video.webm" type="video/webm">
Run Code Online (Sandbox Code Playgroud)

它在chrome和FF上工作正常.但是只要我添加mp4:

<source src="video/video.webm" type="video/webm">
      <source src="video/video.mp4" type="video/mp4">
Run Code Online (Sandbox Code Playgroud)

Chrome显示黑屏和文本"等待视频",但Safari和FF按预期显示.

任何建议,使其在所有这些浏览器上播放将不胜感激.谢谢.

html5 google-chrome html5-video

8
推荐指数
1
解决办法
8万
查看次数