希望你已经创建火力地堡项目,并上载文件存储,你正在寻找加载 请按照下面的指导
安装荚
# Pull in Firebase Storage features
pod 'FirebaseUI/Storage', '~> 0.6'
// Create a reference with an initial file path and name
let pathReference = storage.reference("images/stars.jpg")
// Create a reference from a Google Cloud Storage URI
let gsReference = storage.referenceForURL('gs://bucket/images/stars.jpg')
// Create a reference from an HTTPS URL
// Note that in the URL, characters are URL escaped!
let httpsReference = storage.referenceForURL('https://firebasestorage.googleapis.com/b/bucket/o/images%20stars.jpg')
现在你有三种方式在存储器中取出
下载
// Create a reference to the file you want to download
let islandRef = storageRef.child("images/island.jpg")
// Download in memory with a maximum allowed size of 1MB (1 * 1024 * 1024 bytes)
islandRef.dataWithMaxSize(1 * 1024 * 1024) { (data, error) -> Void in
if (error != nil) {
// Uh-oh, an error occurred!
} else {
// Data for "images/island.jpg" is returned
// ... let islandImage: UIImage! = UIImage(data: data!)
}
}
下载到本地文件
// Create a reference to the file you want to download
let islandRef = storageRef.child("images/island.jpg")
// Create local filesystem URL
let localURL: NSURL! = NSURL(string: "file:///local/images/island.jpg")
// Download to the local filesystem
let downloadTask = islandRef.writeToFile(localURL) { (URL, error) -> Void in
if (error != nil) {
// Uh-oh, an error occurred!
} else {
// Local file URL for "images/island.jpg" is returned
}
}
生成一个下载网址
// Create a reference to the file you want to download
let starsRef = storageRef.child("images/stars.jpg")
// Fetch the download URL
starsRef.downloadURLWithCompletion { (URL, error) -> Void in
if (error != nil) {
// Handle any errors
} else {
// Get the download URL for 'images/stars.jpg'
}
}
脱颖而出更多信息请访问[火力地堡d] [1]
[1]:https://firebase.google.com/docs/storage/ios/download-files你可以用任何文件替换图像文件
从这里开始:https://firebase.google.com/docs/storage/ios/start –