希望你已經創建火力地堡項目,並上載文件存儲,你正在尋找加載 請按照下面的指導
安裝莢
# 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 –