将视频上传到FriendlyPix应用程序

时间:2018-06-20 20:28:49

标签: firebase firebase-storage

我从以下位置更改了storage.rules文件:

// Returns true if the uploaded file is an image and its size is below 
the given number of MB.

function isImageBelowMaxSize(maxSizeMB) {
  return request.resource.size < maxSizeMB * 1024 * 1024
      && request.resource.contentType.matches('image/.*');
}

// Returns true if the user that initiated the request is an admin.
function isAdmin() {
  return request.auth.token != null && request.auth.token.admin == true;
}

// Returns true if the resource is being deleted.
function isResourceBeingDeleted() {
  return request.resource == null;
}

// Returns true if the user is the owner of the file.
function isOwner(uid) {
  return request.auth.uid == uid;
}

service firebase.storage {
  match /b/{bucket}/o {
    match /{userId}/thumb/{postId}/{fileName} {
      allow read;
      allow write: if isAdmin() || isOwner(userId) && 
(isResourceBeingDeleted() || isImageBelowMaxSize(1));
    }
    match /{userId}/full/{postId}/{fileName} {
       allow read;
      allow write: if isAdmin() || isOwner(userId) && 
 (isResourceBeingDeleted() || isImageBelowMaxSize(5));
    }
   }
 }                

至:

  service firebase.storage {
   match /b/rohanathavle-9b77f.appspot.com/o {
     match /{allPaths=**} {
      allow read, write: if true;
    }
  }
} .   

我还更改了inde.html以包括视频的MIME类型:

<input id="fp-mediacapture" type="file" accept="image/* video/*" 
capture="camera">              

根据我已发布的github链接的作者的建议,在Uploader.js中需要进行一些更改。但是这些变化都没有解决。我所做的所有更改都是将image。*更改为v​​ideo。*,即允许代码接受视频。但是这些变化都没有满足我的要求。

0 个答案:

没有答案