-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
feature: 사진 파베 연동 완료
- Loading branch information
Showing
8 changed files
with
237 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...consumer/project02-teamB-OUR-consumer/FeedRecruitModel+Extension/FeedStorageManager.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Foundation | ||
import FirebaseStorage | ||
import FirebaseAuth | ||
import Firebase | ||
|
||
final class FeedStorageManager { | ||
|
||
static let shared = FeedStorageManager() | ||
private init() { } | ||
|
||
private let storage = Storage.storage().reference() | ||
|
||
private var imagesReference: StorageReference { | ||
storage.child("images") | ||
} | ||
|
||
private func userReference(id: String) -> StorageReference { | ||
storage.child("FeedPosts").child(id) | ||
} | ||
|
||
func getSavedImage(id: String, path: String) async throws -> Data { | ||
try await userReference(id: id).child(path).data(maxSize: 3 * 1024 * 1024) | ||
} | ||
|
||
func saveImage(data: Data, id: String) async throws -> (path: String, name: String, url: URL) { | ||
let meta = StorageMetadata() | ||
meta.contentType = "image/jpeg" | ||
|
||
let path = "\(UUID().uuidString).jpeg" | ||
let returnedMetaData = try await userReference(id: id).child(path).putDataAsync(data, metadata: meta) | ||
|
||
guard let returnedPath = returnedMetaData.path, let returnedName = returnedMetaData.name else { | ||
throw URLError(.badURL) | ||
} | ||
|
||
let test = try await userReference(id: id).child(path).downloadURL() | ||
return (returnedPath, returnedName, test) | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.