本文介绍了Firebase存储 - 图片服务的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让Firebase存储与像。但是,Firebase提供的下载网址似乎不适用于这些服务。



例如: Cloudinary 表示您可以像这样获取图片:



然而,我的下载URL看起来更像这样:





我改变了上面的url中的一些字符,所以它不会工作,因为我不希望从Stackoverflow gazillion请求。 :)



有什么我可以做不同的事情吗?我可以直接向存储桶发出请求吗?

解决方案

绝对可以使用像Imgix或Cloudinary这样的服务与Firebase存储网址 - 这里的问题(这是99%的情况是这样的)真正的URL是需要百分比逃脱时使用的抓取。



如果我们有URL: https://firebasestorage.googleapis.com/v0/b/fir-cloudvisiontest.appspot.com/o/images%2Fimage.jpg?alt=media&token=TOKEN
$ p

需要转义为: https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb %2Ffir-cloudvisiontest.appspot.com%2Fo%2Fimages%252Fimage.jpg%3Falt%3Dmedia%26token%3D61d35caf-b209-485f-8248-a3c2aa717468 (是的,它实际上是重新逃脱了逃跑百分比编码)。

这将导致一个Cloudinary URL,如下所示: http://res.cloudinary.com/<your-项目> /image/fetch/https%3A%2F%2Ffirebasestorage.googleapis.com% 2Fv0%2Fb%2Ffir-cloudvisiontest.appspot.com%2Fo%2Fimages%252Fimage.jpg%3Falt%3Dmedia%26token%3DTOKEN



服务差异的URL编码容差,你的里程可能会有所不同,所以我建议使用像来验证您的图片是否有效。


I'm trying to get Firebase Storage to work with an image service like Imgix or Cloudinary. However, the download URL's that Firebase provides, do not seem to work with these services.

For example: Cloudinary says you can fetch images like this:

http://res.cloudinary.com/demo/image/fetch/http://upload.wikimedia.org/wikipedia/commons/0/0c/Scarlett_Johansson_C%C3%A9sars_2014.jpg

However, my download URL looks more like this:

https://firebasestorage.googleapis.com/v0/b/project-503247351211329470.appspot.com/changedsoitdoesnotwork/o/O8Hv4nKOyGgcCyOLoVLH7cQw48y2%2Fimages%2F1.jpeg?alt=media&token=28eabf76-f85b-45aa-das3-fd945729d7c2

I changed some characters in the above url, so it won't work since I don't want a gazillion requests from Stackoverflow. :)

Is there something I can do differently? Can I perhaps make requests straight to the Storage Bucket?

解决方案

You can absolutely use a service like Imgix or Cloudinary with Firebase Storage URLs--the issue here (as is true with 99% of cases like this) is that the URL needs to be percent escaped when used in the fetch.

If we have a URL like: https://firebasestorage.googleapis.com/v0/b/fir-cloudvisiontest.appspot.com/o/images%2Fimage.jpg?alt=media&token=TOKEN

It will need to be escaped to something like: https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Ffir-cloudvisiontest.appspot.com%2Fo%2Fimages%252Fimage.jpg%3Falt%3Dmedia%26token%3D61d35caf-b209-485f-8248-a3c2aa717468 (yes, it actually re-escapes the escaped any percent encoding).

That would result in a Cloudinary URL which looks like: http://res.cloudinary.com/<your-project>/image/fetch/https%3A%2F%2Ffirebasestorage.googleapis.com%2Fv0%2Fb%2Ffir-cloudvisiontest.appspot.com%2Fo%2Fimages%252Fimage.jpg%3Falt%3Dmedia%26token%3DTOKEN

Given service differences in tolerance for URL encoding, your mileage may vary, so I recommend testing URLs with a tool like http://meyerweb.com/eric/tools/dencoder/ to verify that your images work.

这篇关于Firebase存储 - 图片服务的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 01:01