我上传了一个原始的String
使用提供的示例对 firebase 存储进行“测试”here https://firebase.google.com/docs/storage/web/upload-files#upload_from_a_string并成功完成。
但是,当我尝试使用下面的示例“下载”我上传的字符串时,显然他只是关于如何从firebase storage
它返回字符串文件的 url。
storageRef.child('path/to/string').getDownloadURL().then(function(url) {
// I get the url of course
}).catch(function(error) {
// Handle any errors
});
如何从回调中获取文件的内容url
这是“测试”(我上传的字符串。)
简而言之,在 Web Storage SDK 中,您只能获取代表该数据的下载 URL。您需要使用“下载”文件XMLHttpRequest
(或同等学历):
storageRef.child('path/to/string').getDownloadURL().then(function(url) {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
var response = xmlHttp.responseText; // should have your text
}
XMLHttp.open("GET", url, true); // true for asynchronous
XMLHttp.send(null);
}).catch(function(error) {
// Handle any errors from Storage
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)