mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Chat import improvements
This commit is contained in:
parent
50138a33ed
commit
85b937d6c9
@ -454,7 +454,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
private let archivePath: String
|
private let archivePath: String
|
||||||
private let mainEntry: TempBoxFile
|
private let mainEntry: TempBoxFile
|
||||||
private let mainEntrySize: Int
|
private let mainEntrySize: Int
|
||||||
private let otherEntries: [(SSZipEntry, String, ChatHistoryImport.MediaType, Promise<TempBoxFile?>)]
|
private let otherEntries: [(SSZipEntry, String, ChatHistoryImport.MediaType, Signal<TempBoxFile?, NoError>)]
|
||||||
private let totalBytes: Int
|
private let totalBytes: Int
|
||||||
private let totalMediaBytes: Int
|
private let totalMediaBytes: Int
|
||||||
|
|
||||||
@ -480,11 +480,14 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
self.archivePath = archivePath
|
self.archivePath = archivePath
|
||||||
self.mainEntry = mainEntry
|
self.mainEntry = mainEntry
|
||||||
|
|
||||||
self.otherEntries = otherEntries.map { entry -> (SSZipEntry, String, ChatHistoryImport.MediaType, Promise<TempBoxFile?>) in
|
var isFirstFile = true
|
||||||
|
self.otherEntries = otherEntries.map { entry -> (SSZipEntry, String, ChatHistoryImport.MediaType, Signal<TempBoxFile?, NoError>) in
|
||||||
let signal = Signal<TempBoxFile?, NoError> { subscriber in
|
let signal = Signal<TempBoxFile?, NoError> { subscriber in
|
||||||
let tempFile = TempBox.shared.tempFile(fileName: entry.1)
|
let tempFile = TempBox.shared.tempFile(fileName: entry.1)
|
||||||
|
print("Extracting \(entry.0.path) to \(tempFile.path)...")
|
||||||
|
let startTime = CACurrentMediaTime()
|
||||||
if SSZipArchive.extractFileFromArchive(atPath: archivePath, filePath: entry.0.path, toPath: tempFile.path) {
|
if SSZipArchive.extractFileFromArchive(atPath: archivePath, filePath: entry.0.path, toPath: tempFile.path) {
|
||||||
//print("Extract \(entry.0.path) to \(tempFile.path)")
|
print("[Done in \(CACurrentMediaTime() - startTime) s] Extract \(entry.0.path) to \(tempFile.path)")
|
||||||
subscriber.putNext(tempFile)
|
subscriber.putNext(tempFile)
|
||||||
subscriber.putCompletion()
|
subscriber.putCompletion()
|
||||||
} else {
|
} else {
|
||||||
@ -494,10 +497,9 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
|
|
||||||
return EmptyDisposable
|
return EmptyDisposable
|
||||||
}
|
}
|
||||||
|> runOn(Queue.concurrentDefaultQueue())
|
//let promise = Promise<TempBoxFile?>()
|
||||||
let promise = Promise<TempBoxFile?>()
|
//promise.set(signal)
|
||||||
promise.set(signal)
|
return (entry.0, entry.1, entry.2, signal)
|
||||||
return (entry.0, entry.1, entry.2, promise)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let size = fileSize(self.mainEntry.path) {
|
if let size = fileSize(self.mainEntry.path) {
|
||||||
@ -610,7 +612,7 @@ public final class ChatImportActivityScreen: ViewController {
|
|||||||
var mediaSignals: [Signal<(String, Float), ImportError>] = []
|
var mediaSignals: [Signal<(String, Float), ImportError>] = []
|
||||||
|
|
||||||
for (_, fileName, mediaType, fileData) in otherEntries {
|
for (_, fileName, mediaType, fileData) in otherEntries {
|
||||||
let unpackedFile: Signal<TempBoxFile, ImportError> = fileData.get()
|
let unpackedFile: Signal<TempBoxFile, ImportError> = fileData
|
||||||
|> take(1)
|
|> take(1)
|
||||||
|> deliverOnMainQueue
|
|> deliverOnMainQueue
|
||||||
|> castError(ImportError.self)
|
|> castError(ImportError.self)
|
||||||
|
@ -49,7 +49,7 @@ public enum ChatHistoryImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func initSession(account: Account, peerId: PeerId, file: TempBoxFile, mediaCount: Int32) -> Signal<Session, InitImportError> {
|
public static func initSession(account: Account, peerId: PeerId, file: TempBoxFile, mediaCount: Int32) -> Signal<Session, InitImportError> {
|
||||||
return multipartUpload(network: account.network, postbox: account.postbox, source: .tempFile(file), encrypt: false, tag: nil, hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: account.network, postbox: account.postbox, source: .tempFile(file), encrypt: false, tag: nil, hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> InitImportError in
|
|> mapError { _ -> InitImportError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
@ -104,7 +104,12 @@ public enum ChatHistoryImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static func uploadMedia(account: Account, session: Session, file: TempBoxFile, fileName: String, mimeType: String, type: MediaType) -> Signal<Float, UploadMediaError> {
|
public static func uploadMedia(account: Account, session: Session, file: TempBoxFile, fileName: String, mimeType: String, type: MediaType) -> Signal<Float, UploadMediaError> {
|
||||||
return multipartUpload(network: account.network, postbox: account.postbox, source: .tempFile(file), encrypt: false, tag: nil, hintFileSize: nil, hintFileIsLarge: false, useLargerParts: true, useMultiplexedRequests: true)
|
var forceNoBigParts = true
|
||||||
|
if let size = fileSize(file.path), size >= 30 * 1024 * 1024 {
|
||||||
|
forceNoBigParts = false
|
||||||
|
}
|
||||||
|
|
||||||
|
return multipartUpload(network: account.network, postbox: account.postbox, source: .tempFile(file), encrypt: false, tag: nil, hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: forceNoBigParts, useLargerParts: true, useMultiplexedRequests: true)
|
||||||
|> mapError { _ -> UploadMediaError in
|
|> mapError { _ -> UploadMediaError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ private final class MessageMediaPreuploadManagerContext {
|
|||||||
let context = MessageMediaPreuploadManagerUploadContext()
|
let context = MessageMediaPreuploadManagerUploadContext()
|
||||||
self.uploadContexts[id] = context
|
self.uploadContexts[id] = context
|
||||||
let queue = self.queue
|
let queue = self.queue
|
||||||
context.disposable.set(multipartUpload(network: network, postbox: postbox, source: .custom(source), encrypt: encrypt, tag: tag, hintFileSize: nil, hintFileIsLarge: false).start(next: { [weak self] next in
|
context.disposable.set(multipartUpload(network: network, postbox: postbox, source: .custom(source), encrypt: encrypt, tag: tag, hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false).start(next: { [weak self] next in
|
||||||
queue.async {
|
queue.async {
|
||||||
if let strongSelf = self, let context = strongSelf.uploadContexts[id] {
|
if let strongSelf = self, let context = strongSelf.uploadContexts[id] {
|
||||||
switch next {
|
switch next {
|
||||||
@ -86,7 +86,7 @@ private final class MessageMediaPreuploadManagerContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: source, encrypt: encrypt, tag: tag, hintFileSize: hintFileSize, hintFileIsLarge: hintFileIsLarge).start(next: { next in
|
return multipartUpload(network: network, postbox: postbox, source: source, encrypt: encrypt, tag: tag, hintFileSize: hintFileSize, hintFileIsLarge: hintFileIsLarge, forceNoBigParts: false).start(next: { next in
|
||||||
subscriber.putNext(next)
|
subscriber.putNext(next)
|
||||||
}, error: { error in
|
}, error: { error in
|
||||||
subscriber.putError(error)
|
subscriber.putError(error)
|
||||||
|
@ -117,6 +117,7 @@ private final class MultipartUploadManager {
|
|||||||
var defaultPartSize: Int
|
var defaultPartSize: Int
|
||||||
var bigTotalParts: Int?
|
var bigTotalParts: Int?
|
||||||
var bigParts: Bool
|
var bigParts: Bool
|
||||||
|
private let forceNoBigParts: Bool
|
||||||
private let useLargerParts: Bool
|
private let useLargerParts: Bool
|
||||||
|
|
||||||
let queue = Queue()
|
let queue = Queue()
|
||||||
@ -139,13 +140,14 @@ private final class MultipartUploadManager {
|
|||||||
|
|
||||||
let state: MultipartUploadState
|
let state: MultipartUploadState
|
||||||
|
|
||||||
init(headerSize: Int32, data: Signal<MultipartUploadData, NoError>, encryptionKey: SecretFileEncryptionKey?, hintFileSize: Int?, hintFileIsLarge: Bool, useLargerParts: Bool, uploadPart: @escaping (UploadPart) -> Signal<Void, UploadPartError>, progress: @escaping (Float) -> Void, completed: @escaping (MultipartIntermediateResult?) -> Void) {
|
init(headerSize: Int32, data: Signal<MultipartUploadData, NoError>, encryptionKey: SecretFileEncryptionKey?, hintFileSize: Int?, hintFileIsLarge: Bool, forceNoBigParts: Bool, useLargerParts: Bool, uploadPart: @escaping (UploadPart) -> Signal<Void, UploadPartError>, progress: @escaping (Float) -> Void, completed: @escaping (MultipartIntermediateResult?) -> Void) {
|
||||||
self.dataSignal = data
|
self.dataSignal = data
|
||||||
|
|
||||||
var fileId: Int64 = 0
|
var fileId: Int64 = 0
|
||||||
arc4random_buf(&fileId, 8)
|
arc4random_buf(&fileId, 8)
|
||||||
self.fileId = fileId
|
self.fileId = fileId
|
||||||
|
|
||||||
|
self.forceNoBigParts = forceNoBigParts
|
||||||
self.useLargerParts = useLargerParts
|
self.useLargerParts = useLargerParts
|
||||||
|
|
||||||
self.state = MultipartUploadState(encryptionKey: encryptionKey)
|
self.state = MultipartUploadState(encryptionKey: encryptionKey)
|
||||||
@ -161,11 +163,11 @@ private final class MultipartUploadManager {
|
|||||||
self.headerPartState = .notStarted
|
self.headerPartState = .notStarted
|
||||||
}
|
}
|
||||||
|
|
||||||
if let hintFileSize = hintFileSize, hintFileSize > 10 * 1024 * 1024 {
|
if let hintFileSize = hintFileSize, hintFileSize > 10 * 1024 * 1024, !forceNoBigParts {
|
||||||
self.defaultPartSize = 512 * 1024
|
self.defaultPartSize = 512 * 1024
|
||||||
self.bigTotalParts = (hintFileSize / self.defaultPartSize) + (hintFileSize % self.defaultPartSize == 0 ? 0 : 1)
|
self.bigTotalParts = (hintFileSize / self.defaultPartSize) + (hintFileSize % self.defaultPartSize == 0 ? 0 : 1)
|
||||||
self.bigParts = true
|
self.bigParts = true
|
||||||
} else if hintFileIsLarge {
|
} else if hintFileIsLarge, !forceNoBigParts {
|
||||||
self.defaultPartSize = 512 * 1024
|
self.defaultPartSize = 512 * 1024
|
||||||
self.bigTotalParts = nil
|
self.bigTotalParts = nil
|
||||||
self.bigParts = true
|
self.bigParts = true
|
||||||
@ -203,7 +205,7 @@ private final class MultipartUploadManager {
|
|||||||
func checkState() {
|
func checkState() {
|
||||||
if let resourceData = self.resourceData, resourceData.complete && resourceData.size != 0 {
|
if let resourceData = self.resourceData, resourceData.complete && resourceData.size != 0 {
|
||||||
if self.committedOffset == 0 && self.uploadedParts.isEmpty && self.uploadingParts.isEmpty {
|
if self.committedOffset == 0 && self.uploadedParts.isEmpty && self.uploadingParts.isEmpty {
|
||||||
if resourceData.size > 10 * 1024 * 1024 {
|
if resourceData.size > 10 * 1024 * 1024, !self.forceNoBigParts {
|
||||||
self.defaultPartSize = 512 * 1024
|
self.defaultPartSize = 512 * 1024
|
||||||
self.bigTotalParts = (resourceData.size / self.defaultPartSize) + (resourceData.size % self.defaultPartSize == 0 ? 0 : 1)
|
self.bigTotalParts = (resourceData.size / self.defaultPartSize) + (resourceData.size % self.defaultPartSize == 0 ? 0 : 1)
|
||||||
self.bigParts = true
|
self.bigParts = true
|
||||||
@ -379,7 +381,7 @@ enum MultipartUploadError {
|
|||||||
case generic
|
case generic
|
||||||
}
|
}
|
||||||
|
|
||||||
func multipartUpload(network: Network, postbox: Postbox, source: MultipartUploadSource, encrypt: Bool, tag: MediaResourceFetchTag?, hintFileSize: Int?, hintFileIsLarge: Bool, useLargerParts: Bool = false, useMultiplexedRequests: Bool = false) -> Signal<MultipartUploadResult, MultipartUploadError> {
|
func multipartUpload(network: Network, postbox: Postbox, source: MultipartUploadSource, encrypt: Bool, tag: MediaResourceFetchTag?, hintFileSize: Int?, hintFileIsLarge: Bool, forceNoBigParts: Bool, useLargerParts: Bool = false, useMultiplexedRequests: Bool = false) -> Signal<MultipartUploadResult, MultipartUploadError> {
|
||||||
enum UploadInterface {
|
enum UploadInterface {
|
||||||
case download(Download)
|
case download(Download)
|
||||||
case multiplexed(manager: MultiplexedRequestManager, datacenterId: Int, consumerId: Int64)
|
case multiplexed(manager: MultiplexedRequestManager, datacenterId: Int, consumerId: Int64)
|
||||||
@ -445,7 +447,7 @@ func multipartUpload(network: Network, postbox: Postbox, source: MultipartUpload
|
|||||||
fetchedResource = .complete()
|
fetchedResource = .complete()
|
||||||
}
|
}
|
||||||
|
|
||||||
let manager = MultipartUploadManager(headerSize: headerSize, data: dataSignal, encryptionKey: encryptionKey, hintFileSize: hintFileSize, hintFileIsLarge: hintFileIsLarge, useLargerParts: useLargerParts, uploadPart: { part in
|
let manager = MultipartUploadManager(headerSize: headerSize, data: dataSignal, encryptionKey: encryptionKey, hintFileSize: hintFileSize, hintFileIsLarge: hintFileIsLarge, forceNoBigParts: forceNoBigParts, useLargerParts: useLargerParts, uploadPart: { part in
|
||||||
switch uploadInterface {
|
switch uploadInterface {
|
||||||
case let .download(download):
|
case let .download(download):
|
||||||
return download.uploadPart(fileId: part.fileId, index: part.index, data: part.data, asBigPart: part.bigPart, bigTotalParts: part.bigTotalParts)
|
return download.uploadPart(fileId: part.fileId, index: part.index, data: part.data, asBigPart: part.bigPart, bigTotalParts: part.bigTotalParts)
|
||||||
|
@ -38,7 +38,7 @@ enum UploadedPeerPhotoDataContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func uploadedPeerPhoto(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedPeerPhotoData, NoError> {
|
public func uploadedPeerPhoto(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedPeerPhotoData, NoError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> map { result -> UploadedPeerPhotoData in
|
|> map { result -> UploadedPeerPhotoData in
|
||||||
return UploadedPeerPhotoData(resource: resource, content: .result(result))
|
return UploadedPeerPhotoData(resource: resource, content: .result(result))
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ public func uploadedPeerVideo(postbox: Postbox, network: Network, messageMediaPr
|
|||||||
return .single(UploadedPeerPhotoData(resource: resource, content: .error))
|
return .single(UploadedPeerPhotoData(resource: resource, content: .error))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .video), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .video), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> map { result -> UploadedPeerPhotoData in
|
|> map { result -> UploadedPeerPhotoData in
|
||||||
return UploadedPeerPhotoData(resource: resource, content: .result(result))
|
return UploadedPeerPhotoData(resource: resource, content: .result(result))
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ private func uploadedMediaImageContent(network: Network, postbox: Postbox, trans
|
|||||||
} else {
|
} else {
|
||||||
imageReference = .standalone(media: transformedImage)
|
imageReference = .standalone(media: transformedImage)
|
||||||
}
|
}
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(imageReference.resourceReference(largestRepresentation.resource)), encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(imageReference.resourceReference(largestRepresentation.resource)), encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
||||||
|> mapToSignal { next -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> in
|
|> mapToSignal { next -> Signal<PendingMessageUploadedContentResult, PendingMessageUploadError> in
|
||||||
switch next {
|
switch next {
|
||||||
@ -560,7 +560,7 @@ private enum UploadedMediaFileAndThumbnail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedThumbnail(network: Network, postbox: Postbox, resourceReference: MediaResourceReference) -> Signal<Api.InputFile?, PendingMessageUploadError> {
|
private func uploadedThumbnail(network: Network, postbox: Postbox, resourceReference: MediaResourceReference) -> Signal<Api.InputFile?, PendingMessageUploadError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(resourceReference), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(resourceReference), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
||||||
|> mapToSignal { result -> Signal<Api.InputFile?, PendingMessageUploadError> in
|
|> mapToSignal { result -> Signal<Api.InputFile?, PendingMessageUploadError> in
|
||||||
switch result {
|
switch result {
|
||||||
|
@ -144,7 +144,7 @@ private enum UploadMediaEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedImage(account: Account, data: Data) -> Signal<UploadMediaEvent, StandaloneSendMessageError> {
|
private func uploadedImage(account: Account, data: Data) -> Signal<UploadMediaEvent, StandaloneSendMessageError> {
|
||||||
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> StandaloneSendMessageError in return .generic }
|
|> mapError { _ -> StandaloneSendMessageError in return .generic }
|
||||||
|> map { next -> UploadMediaEvent in
|
|> map { next -> UploadMediaEvent in
|
||||||
switch next {
|
switch next {
|
||||||
@ -159,7 +159,7 @@ private func uploadedImage(account: Account, data: Data) -> Signal<UploadMediaEv
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedFile(account: Account, data: Data, mimeType: String, attributes: [TelegramMediaFileAttribute]) -> Signal<UploadMediaEvent, PendingMessageUploadError> {
|
private func uploadedFile(account: Account, data: Data, mimeType: String, attributes: [TelegramMediaFileAttribute]) -> Signal<UploadMediaEvent, PendingMessageUploadError> {
|
||||||
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: statsCategoryForFileWithAttributes(attributes)), hintFileSize: data.count, hintFileIsLarge: false)
|
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: statsCategoryForFileWithAttributes(attributes)), hintFileSize: data.count, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
|> mapError { _ -> PendingMessageUploadError in return .generic }
|
||||||
|> map { next -> UploadMediaEvent in
|
|> map { next -> UploadMediaEvent in
|
||||||
switch next {
|
switch next {
|
||||||
|
@ -39,7 +39,7 @@ public enum StandaloneUploadMediaEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedThumbnail(network: Network, postbox: Postbox, data: Data) -> Signal<Api.InputFile?, StandaloneUploadMediaError> {
|
private func uploadedThumbnail(network: Network, postbox: Postbox, data: Data) -> Signal<Api.InputFile?, StandaloneUploadMediaError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
||||||
|> mapToSignal { result -> Signal<Api.InputFile?, StandaloneUploadMediaError> in
|
|> mapToSignal { result -> Signal<Api.InputFile?, StandaloneUploadMediaError> in
|
||||||
switch result {
|
switch result {
|
||||||
@ -54,7 +54,7 @@ private func uploadedThumbnail(network: Network, postbox: Postbox, data: Data) -
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func standaloneUploadedImage(account: Account, peerId: PeerId, text: String, data: Data, thumbnailData: Data? = nil, dimensions: PixelDimensions) -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> {
|
public func standaloneUploadedImage(account: Account, peerId: PeerId, text: String, data: Data, thumbnailData: Data? = nil, dimensions: PixelDimensions) -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> {
|
||||||
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: account.network, postbox: account.postbox, source: .data(data), encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
||||||
|> mapToSignal { next -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
|> mapToSignal { next -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> in
|
||||||
switch next {
|
switch next {
|
||||||
@ -115,7 +115,7 @@ public func standaloneUploadedImage(account: Account, peerId: PeerId, text: Stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func standaloneUploadedFile(account: Account, peerId: PeerId, text: String, source: MultipartUploadSource, thumbnailData: Data? = nil, mimeType: String, attributes: [TelegramMediaFileAttribute], hintFileIsLarge: Bool) -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> {
|
public func standaloneUploadedFile(account: Account, peerId: PeerId, text: String, source: MultipartUploadSource, thumbnailData: Data? = nil, mimeType: String, attributes: [TelegramMediaFileAttribute], hintFileIsLarge: Bool) -> Signal<StandaloneUploadMediaEvent, StandaloneUploadMediaError> {
|
||||||
let upload = multipartUpload(network: account.network, postbox: account.postbox, source: source, encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: statsCategoryForFileWithAttributes(attributes)), hintFileSize: nil, hintFileIsLarge: hintFileIsLarge)
|
let upload = multipartUpload(network: account.network, postbox: account.postbox, source: source, encrypt: peerId.namespace == Namespaces.Peer.SecretChat, tag: TelegramMediaResourceFetchTag(statsCategory: statsCategoryForFileWithAttributes(attributes)), hintFileSize: nil, hintFileIsLarge: hintFileIsLarge, forceNoBigParts: false)
|
||||||
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
|> mapError { _ -> StandaloneUploadMediaError in return .generic }
|
||||||
|
|
||||||
let uploadThumbnail: Signal<StandaloneUploadMediaThumbnailResult, StandaloneUploadMediaError>
|
let uploadThumbnail: Signal<StandaloneUploadMediaThumbnailResult, StandaloneUploadMediaError>
|
||||||
|
@ -203,7 +203,7 @@ private enum UploadedThemeDataContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedTheme(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedThemeData, NoError> {
|
private func uploadedTheme(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedThemeData, NoError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .file), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .file), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> map { result -> UploadedThemeData in
|
|> map { result -> UploadedThemeData in
|
||||||
return UploadedThemeData(content: .result(result))
|
return UploadedThemeData(content: .result(result))
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ private func uploadedTheme(postbox: Postbox, network: Network, resource: MediaRe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedThemeThumbnail(postbox: Postbox, network: Network, data: Data) -> Signal<UploadedThemeData, NoError> {
|
private func uploadedThemeThumbnail(postbox: Postbox, network: Network, data: Data) -> Signal<UploadedThemeData, NoError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .data(data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> map { result -> UploadedThemeData in
|
|> map { result -> UploadedThemeData in
|
||||||
return UploadedThemeData(content: .result(result))
|
return UploadedThemeData(content: .result(result))
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ public func uploadSecureIdFile(context: SecureIdAccessContext, postbox: Postbox,
|
|||||||
return .fail(.generic)
|
return .fail(.generic)
|
||||||
}
|
}
|
||||||
|
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .data(encryptedData.data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .data(encryptedData.data), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> mapError { _ -> UploadSecureIdFileError in
|
|> mapError { _ -> UploadSecureIdFileError in
|
||||||
return .generic
|
return .generic
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ private enum UploadedWallpaperDataContent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func uploadedWallpaper(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedWallpaperData, NoError> {
|
private func uploadedWallpaper(postbox: Postbox, network: Network, resource: MediaResource) -> Signal<UploadedWallpaperData, NoError> {
|
||||||
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false)
|
return multipartUpload(network: network, postbox: postbox, source: .resource(.standalone(resource: resource)), encrypt: false, tag: TelegramMediaResourceFetchTag(statsCategory: .image), hintFileSize: nil, hintFileIsLarge: false, forceNoBigParts: false)
|
||||||
|> map { result -> UploadedWallpaperData in
|
|> map { result -> UploadedWallpaperData in
|
||||||
return UploadedWallpaperData(resource: resource, content: .result(result))
|
return UploadedWallpaperData(resource: resource, content: .result(result))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user