新しい Firebase API を使用すると、クライアント コードからクラウド ストレージにファイルをアップロードできます。例では、アップロード時にファイル名が既知または静的であると想定しています。
// Create a root reference
var storageRef = firebase.storage().ref();
// Create a reference to 'mountains.jpg'
var mountainsRef = storageRef.child('mountains.jpg');
// Create a reference to 'images/mountains.jpg'
var mountainImagesRef = storageRef.child('images/mountains.jpg');
また
// File or Blob, assume the file is called rivers.jpg
var file = ...
// Upload the file to the path 'images/rivers.jpg'
// We can use the 'name' property on the File API to get our file name
var uploadTask = storageRef.child('images/' + file.name).put(file);
ユーザーが自分のファイルをアップロードすると、名前の競合が問題になります。自分で定義するのではなく、Firebase にファイル名を作成させるにはどうすればよいですか? push()
一意のストレージ参照を作成するためのデータベースに機能のようなものはありますか?