是否有任何逻辑可以在 angularjs 控制器中重命名 firebase 上传文件

Is there any logic possible to rename firebase upload file in angularjs controller

我想在将上传的文件存储到 firebase 存储之前使用一些正则表达式重命名它们。

据我所知,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!');
});
Property         Type      Writable
bucket           string    NO
generation       string    NO
metageneration   string    NO
fullPath         string    NO
name             string    NO

很遗憾,名称不可编辑属性:https://firebase.google.com/docs/storage/web/file-metadata#file_metadata_properties