mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:02:10 +00:00
* #748 - Implement methods for processing various media types and preparing them for upload * Various tweaks following code review: - added blurhash generation - changed thumbnails to jpeg - throwing if file size cannot be retrieved - move MediaProvider files to separate folder so they can cleanly be imported in the NSE - added audio file processing - switched all image resizing methods to ImageIO - various renames * Fix blurhash formatting issues, `swift-format-ignore-file` doesn't work * Processing all media within unique folders to avoid conflicts * Fix various warnings * Rename `sizeForItemAt(_ url: URL)` to `sizeForItem(at url: URL)` * Remove unnecessary resizeImage(UIImage) method, start by copying not moving the file to the unique location * Add back warning for roomDetails.avatarURL
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
enum FileManagerError: Error {
|
||||
case invalidFileSize
|
||||
}
|
||||
|
||||
extension FileManager {
|
||||
func directoryExists(at url: URL) -> Bool {
|
||||
var isDirectory: ObjCBool = false
|
||||
@@ -32,7 +36,7 @@ extension FileManager {
|
||||
try createDirectory(at: url, withIntermediateDirectories: withIntermediateDirectories)
|
||||
}
|
||||
|
||||
func copyFileToTemporaryDirectory(url: URL) throws -> URL {
|
||||
func copyFileToTemporaryDirectory(file url: URL) throws -> URL {
|
||||
let newURL = URL.temporaryDirectory.appendingPathComponent(url.lastPathComponent)
|
||||
|
||||
try? removeItem(at: newURL)
|
||||
@@ -48,4 +52,17 @@ extension FileManager {
|
||||
|
||||
return newURL
|
||||
}
|
||||
|
||||
/// Retrieve a file's disk size
|
||||
/// - Parameter url: the file URL
|
||||
/// - Returns: the size in bytes
|
||||
func sizeForItem(at url: URL) throws -> Double {
|
||||
let attributes = try attributesOfItem(atPath: url.path())
|
||||
|
||||
guard let size = attributes[FileAttributeKey.size] as? Double else {
|
||||
throw FileManagerError.invalidFileSize
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user