Javascript 当上传到同一路径时,如何强制firebase存储返回新的签名url?

Javascript 当上传到同一路径时,如何强制firebase存储返回新的签名url?,javascript,firebase,google-cloud-storage,firebase-storage,react-native-firebase,Javascript,Firebase,Google Cloud Storage,Firebase Storage,React Native Firebase,我正在将用户配置文件的图像上载到Firebase,路径为profiles/${userId}/image.jpg 每次上传后,我都会触发一个云函数,该函数使用GCS获取签名url,如本例所示: const SIGNED\u BUCKET\u URL\u CONFIG={ 行动:“读”, 过期日期:“03-01-2501” }; const bucket=gcs.bucket(bucket\u名称); const profileImageRef=bucket.file(`profiles/${u

我正在将用户配置文件的图像上载到Firebase,路径为
profiles/${userId}/image.jpg

每次上传后,我都会触发一个云函数,该函数使用GCS获取签名url,如本例所示:

const SIGNED\u BUCKET\u URL\u CONFIG={
行动:“读”,
过期日期:“03-01-2501”
};
const bucket=gcs.bucket(bucket\u名称);
const profileImageRef=bucket.file(`profiles/${userId}/image.jpg`);

const url=profileImageRef.getSignedUrl(SIGNED_BUCKET_url_CONFIG),
实现这一点的简单方法是提供
SIGNED_BUCKET_url_CONFIG
动态配置,如下所示:

const exp = Date.now() + 30 * 365 * 24 * 60 * 60 * 1000; // 30 years from now

const SIGNED_BUCKET_URL_CONFIG = {
    action: 'read',
    expires: exp
};
但如果在同一毫秒内进行多次上传,上述技术可能会失败。因此,仅当您的项目可以接受此方法时才选择此方法。

您可以使用generation:生成带有版本的签名url。