-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create POC for uploading photos in the background
- Loading branch information
Showing
16 changed files
with
934 additions
and
18 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
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
43 changes: 43 additions & 0 deletions
43
Permanent/Modules/PhotoAlbum/Managers/OtherUploadManager.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,43 @@ | ||
// | ||
// UploadManager.swift | ||
// VSPFetchAssets | ||
// | ||
// Created by Flaviu Silaghi on 09.10.2024. | ||
|
||
import Foundation | ||
|
||
class OtherUploadManager { | ||
|
||
static let shared = OtherUploadManager() | ||
|
||
let uploadQueue: OperationQueue = OperationQueue() | ||
|
||
init() { | ||
uploadQueue.maxConcurrentOperationCount = 1 | ||
} | ||
|
||
func upload(files: [FileInfo]) async { | ||
for file in files { | ||
let uploadOperation = OtherUploadOperation(file: file) { error in | ||
if error == nil { | ||
FileHelper().deleteFile(at: file.url) | ||
} else { | ||
print("Fail") | ||
} | ||
} | ||
|
||
uploadOperation.name = file.id | ||
uploadQueue.addOperation(uploadOperation) | ||
} | ||
|
||
await withCheckedContinuation { continuation in // Use continuation to await barrier block | ||
uploadQueue.addBarrierBlock { | ||
DispatchQueue.main.async { | ||
continuation.resume() // Resume after barrier block executes | ||
print(" Resume after barrier block executes") | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.