我在我的应用程序中使用了 firebase 存储,并且我正在使用我自己的用户名和密码身份验证服务,我已将规则更改为公开以便我可以上传和下载数据,但现在它给了我这个警告
您的安全规则设置为公开。任何人都可以读取或写入您的存储分区
如何在不使用任何 Firebase 登录或身份验证方法的情况下保护应用数据?
我正在尝试使用 gsutil 根据谷歌的说明使用最新版本的 MacOS 在我的 firebase 存储桶上设置 CORS。我不确定我是否没有正确安装 gsutil 或者是否还有其他我不明白的东西,但是当我运行时gsutil cors set cors.json gs://docavea2.appspot.com出现以下错误:
Setting CORS on gs://docavea2.appspot.com/...
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/jr/google-cloud-sdk/platform/gsutil/gslib/__init__.py", line 119, in <module>
CHECKSUM_FILE, CHECKSUM = _GetFileContents('CHECKSUM')
File "/Users/jr/google-cloud-sdk/platform/gsutil/gslib/__init__.py", line 107, in _GetFileContents
content = pkgutil.get_data('gslib', filename)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 591, in get_data
return loader.get_data(resource_name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 255, in get_data
return open(pathname, "rb").read()
IOError: [Errno 2] No such file or directory: '/Users/jr/google-cloud-sdk/platform/gsutil/gslib/CHECKSUM'
Run Code Online (Sandbox Code Playgroud)
我认为我的 cors.json 很好,因为当我在 …
我想在我的APP中进行一些UI修改,其中包括Firebase存储.因此,出于临时目的,我想在Firebase中更改捆绑包标识符.有没有办法做到这一点?
我正在使用 firebase,我将图像存储在我的 firebase 存储上,然后在视图上显示这些图像,每个图像都有一个按钮,这个想法是当用户按下按钮时下载图像,到目前为止我该怎么做我一直无法找到使用 angular 的方法,在图像对象上,我存储了downloadUrl上传图像时提供的火库,我想使用该 URL 下载图像
成分
<div class="wrapper-gallery" id="photos_container">
<div class="mix col-xs-12 col-sm-4 col-md-3 item-photo" *ngFor="let photo of couplePhotos | async | sortByFavorites: sortBy | sortByTime: sortBy">
<div class="photo">
<img class="img-fluid" src="{{photo.data.photo_url}}" alt="{{photo.data.name}}">
<button class="delete" (click)="deletePhoto(photo.id, photo.data.name)"><span class="icon-cross"></span></button>
<a class="search zoom" data-fancybox="wedding" href="{{photo.data.photo_url}}"><span class="icon-search"></span></a>
<button class="star" [ngClass]="{'start-on': photo.data.favorite == true}" (click)="toggleFavorite(photo.id, photo)"><span class="icon-star-full"></span></button>
<button class="download" (click)="downloadImg()"><span class="icon-download"></span></button>
<a [href]="photo.data.photo_url" download></a>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud) 我正在构建一个允许用户将图片上传到 firebase 存储的 android 应用程序。我仍处于开发模式,因此我将存储规则设置为公开。当用户选择要上传的图片时,不会上传文件,而是返回下载地址。Logcat 显示以下错误
E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
Run Code Online (Sandbox Code Playgroud)
这是我的存储规则
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read, write;
}
}
}
Run Code Online (Sandbox Code Playgroud)
还有我的 android java 代码:
private void uploadPic() {
StorageReference mStorageRef = FirebaseStorage.getInstance().getReference();
Uri fileUrl = Uri.fromFile(new File(filePath));
String fileExt = MimeTypeMap.getFileExtensionFromUrl(fileUrl.toString());
final String fileName = UUID.randomUUID().toString()+"."+fileExt;
StorageReference profilePicsRef = mStorageRef.child("profile_pics/"+fileName);
profilePicsRef.putFile(fileUrl)
.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// Get a …Run Code Online (Sandbox Code Playgroud) 这是我的 firebase.json。我正在尝试将 /sitemaps 重定向到 Firebase 存储中动态生成的站点地图。不幸的是,重写其余路由的通配符会覆盖重定向。指定重写除该 url 之外的所有内容的最佳方式是什么?
"redirects": [
{
"source" : "/sitemaps",
"destination" : "https://firebasestorage.googleapis.com/v0/b/foo",
"type" : 301
}
],
"rewrites": [
{
"source": "**",
"function": "bar"
}
]
Run Code Online (Sandbox Code Playgroud) 我正在开发 Flutter 应用程序,我想将 PDF 文件上传到 Firebase 存储,我使用 Documents_picker 选择文件,但无法将其上传到存储...请帮助我...我的代码如下
uploaddoc()async{
dynamic docPaths;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
docPaths = await DocumentsPicker.pickDocuments;
final Directory tempDir = Directory.systemTemp;
final String fileName = "${Random().nextInt(10000)}.pdf";
final File file = File('${tempDir.path}/$fileName');
file.writeAsBytesSync(docPaths);
final StorageReference ref = FirebaseStorage.instance.ref().child(fileName);
final StorageUploadTask task = ref.putFile(file);
final Uri downloadUrl = (await task.future).downloadUrl;
_path = downloadUrl.toString();
print(_path);
} on PlatformException {
}
// If the widget was removed from the tree while …Run Code Online (Sandbox Code Playgroud) 该谷歌云存储文件的download()建议,目标文件夹可以指定:
file.download({
destination: '/Users/me/Desktop/file-backup.txt'
}, function(err) {});
Run Code Online (Sandbox Code Playgroud)
无论我在文件中输入什么值,它都会在根级别下载到 Firebase Cloud Storage。这个问题说路径不能有初始斜杠但将示例更改为
file.download({
destination: 'Users/me/Desktop/file-backup.txt'
}, function(err) {});
Run Code Online (Sandbox Code Playgroud)
没什么区别。
将目的地更改为
file.download({
destination: ".child('Test_Folder')",
})
Run Code Online (Sandbox Code Playgroud)
导致错误消息:
EROFS: read-only file system, open '.child('Test_Folder')'
Run Code Online (Sandbox Code Playgroud)
云存储destination(文件夹和文件名)的正确语法是什么?
将存储桶从 更改myapp.appspot.com为myapp.appspot.com/Test_Folder导致错误消息:
Cannot parse JSON response
Run Code Online (Sandbox Code Playgroud)
此外,示例路径似乎指定了个人计算机硬盘驱动器上的位置。为Desktop. 这是否意味着有一种方法可以在 Cloud Storage 之外的某个地方指定目的地?
这是我的代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.Storage = functions.firestore.document('Storage_Value').onUpdate((change, context) => {
const {Storage} = require('@google-cloud/storage');
const storage = new …Run Code Online (Sandbox Code Playgroud) google-cloud-storage firebase google-cloud-functions firebase-storage
我正在尝试使用以下代码将图像上传到Flutter中的Firebase存储。
StorageReference reference =
FirebaseStorage.instance.ref().child("$fileId.jpg");
StorageUploadTask uploadTask = reference.putFile(_imageFile);
Run Code Online (Sandbox Code Playgroud)
这似乎确实有效。但我需要找到一种方法来等待此上传过程。考虑到reference.putFile(file)这不会返回未来,我该怎么办?
我正在尝试在我的 React 应用程序中显示来自 Firebase 存储的图像。我可以使用 listall 从 Firebase Storage 获取所有图像。但我不知道如何在 ui 上显示这些。我尝试使用 map 方法但没有用。另外,即使页面重新加载,我也想保持这些显示。我应该使用 localstrage 还是 useEffect?
请帮助我。这是我的代码。
const PhotoButton = () => {
var storageRef = firebase.storage().ref("images");
const [image, setImage] = useState("");
const [imageUrl, setImageUrl] = useState([]);
const handleImage = event => {
const image = event.target.files[0];
setImage(image);
};
const onSubmit = event => {
event.preventDefault();
if (image === "") {
console.log(“error);
return;
}
const uploadTask = storage.ref(`/images/${image.name}`).put(image);
uploadTask.on(
firebase.storage.TaskEvent.STATE_CHANGED,
next,
error,
complete
);
};
const complete = () …Run Code Online (Sandbox Code Playgroud)