我想在将上传的文件存储在 firebase 存储中之前使用一些 reGex 重命名它们。
据我所知,Firebase 文件元数据不允许这样做。我想知道是否有可能做到这一点。我正在使用 angularjs。
最佳答案
将文件上传到 Firebase 存储时,您需要显式指定该文件的名称。来自 documentation on uploading files :
// Create a root reference
var storageRef = firebase.storage().ref();
// Create a reference to 'mountains.jpg'
var mountainsRef = storageRef.child('mountains.jpg');
现在,无论您上传什么文件,它都会在 Firebase 存储中命名为 mountains.jpg
。例如:
var file = ... // use the Blob or File API
mountainsRef.put(file).then(function(snapshot) {
console.log('Uploaded a blob or file!');
});
关于javascript - 是否有任何逻辑可以在 angularjs Controller 中重命名 firebase 上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39193339/