Firebase 将视频上载到FriendlyPix应用程序
我换了储藏室。规则文件来自:Firebase 将视频上载到FriendlyPix应用程序,firebase,firebase-storage,Firebase,Firebase Storage,我换了储藏室。规则文件来自: // 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.co
// 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));
}
}
}
我还更改了index.html以包含视频的MIME类型:
<input id="fp-mediacapture" type="file" accept="image/* video/*"
capture="camera">
正如我发布的GitHub链接的作者所建议的那样,Uploader.js中需要进行一些更改。但这些变化都没有奏效。我所做的所有更改都是将image.*更改为video.*即允许代码接受视频。但这些变化都不是我想要的 我建议您显示您正在使用的特定、相关的代码,以及您已经尝试过的更改,以便按照您想要的方式进行操作。我将storage.rules文件更改为:我怀疑这与
Uploader.js
有关。
<input id="fp-mediacapture" type="file" accept="image/* video/*"
capture="camera">