在ios中上传后如何从firebase获取缩略图?
我正在将视频和图像上传到swift中的firebase。现在,当上传完成,然后我得到的图像网址。但url是原始图像。我想当图像或视频上传时,我应该为图像或视频获取Thumnbail图像。我正在使用下面的代码在ios中上传后如何从firebase获取缩略图?,ios,swift,image,firebase,firebase-storage,Ios,Swift,Image,Firebase,Firebase Storage,我正在将视频和图像上传到swift中的firebase。现在,当上传完成,然后我得到的图像网址。但url是原始图像。我想当图像或视频上传时,我应该为图像或视频获取Thumnbail图像。我正在使用下面的代码 let imagePath = withName let metadata = FIRStorageMetadata() metadata.contentType = mimeType metadata.customMetadata = ["
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)
}
我们举了一个如何使用云存储的云函数生成缩略图的示例:
缩略图会保存回云存储,然后您可以下载大小合适的照片。FIRStorage仅用于存储数据。它不会自动创建缩略图。您需要使用Firebase函数并添加生成缩略图的代码。这仅适用于图像。我应该使用什么来获取视频文件的缩略图?