gpt4 book ai didi

ios - 在 ios 中上传后如何从 firebase 获取缩略图?

转载 作者:搜寻专家 更新时间:2023-10-31 22:56:56 24 4
gpt4 key购买 nike

我正在快速将视频和图像上传到 firebase。现在,当上传完成后,我将获得图片网址。但网址是原始图片。我希望在上传图像或视频时,我应该得到图像或视频的缩略图。我正在使用以下代码。

let imagePath = withName

let metadata = FIRStorageMetadata()
metadata.contentType = mimeType
metadata.customMetadata = ["index": String(describing: index), "contentType": mimeType]

// Upload file and metadata to the object 'images/mountains.jpg'
let uploadTask = storageRef.child(imagePath).put(data, metadata: metadata)

// Listen for state changes, errors, and completion of the upload.
uploadTask.observe(.resume) { snapshot in
// Upload resumed, also fires when the upload starts
}

uploadTask.observe(.pause) { snapshot in
// Upload paused
}

uploadTask.observe(.progress) { snapshot in
// Upload reported progress
let percentComplete = Double((snapshot.progress?.completedUnitCount)!)/Double(snapshot.progress!.totalUnitCount)
progress( String(format: "%.2f", percentComplete))
print(percentComplete)
}

uploadTask.observe(.success) { snapshot in
// Upload completed successfully
//Download the the image from url and save it as Data in local directory
print(snapshot.metadata?.downloadURL()?.absoluteString ?? "no url found......")
completion(.success, (snapshot.metadata?.downloadURL()?.absoluteString), DIError.noResponse)

// self.startDownloading(downloadUrl: (snapshot.metadata?.downloadURL()?.absoluteString)!, imageName: imagePath)
}

最佳答案

我们有一个示例,说明如何将 Cloud Functions 与 Cloud Storage 结合使用来生成缩略图:https://github.com/firebase/functions-samples/tree/master/generate-thumbnail

缩略图会保存回 Cloud Storage,然后您可以下载适当大小的照片。

关于ios - 在 ios 中上传后如何从 firebase 获取缩略图?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44717259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com