Search
 
SCRIPT & CODE EXAMPLE
 

SWIFT

swift file size from url

do {
    let resources = try url.resourceValues(forKeys:[.fileSizeKey])
    let fileSize = resources.fileSize!
    print ("(fileSize)")
} catch {
    print("Error: (error)")
}
Comment

swift get file size from url

extension URL {
    func fileSizeInMB() -> Double {
        var fileSize: Double = 0.0
        var fileSizeValue = 0.0
        try? fileSizeValue = (self.resourceValues(forKeys: [URLResourceKey.fileSizeKey]).allValues.first?.value as! Double?)!
        if fileSizeValue > 0.0 {
            fileSize = (Double(fileSizeValue) / (1024 * 1024))
        }
        return fileSize
    }
}
Comment

PREVIOUS NEXT
Code Example
Swift :: swift uilabel dynamic height based on text length 
Swift :: how to show notification icon on tabbar item swift 
Swift :: setting a local notification at specific time every day swift 
Swift :: swift split string into array of 2 characters 
Swift :: swift extension Array with element 
Swift :: how to include a library in swift 
Swift :: swift int to int32 
Swift :: swiftui hidden 
Swift :: swift enum storyboard 
Swift :: swft view 
Swift :: two variable sum 
Swift :: clothes that you wear in Diwali 
Swift :: Swift Remove an Element from a Set 
Swift :: Swift Change Value of a Variable 
Swift :: Swift Symmetric Difference between Two Sets 
Swift :: To get IPAddress for wifi , wired, and cellular 
Swift :: Swift Raw Values VS Associated Values 
Swift :: Swift Function overloading with Argument Label 
Swift :: Swift Check Subset of a Set 
Swift :: Swift Explicitly declaring an unwrapped optional 
Swift :: Typealias for built-in types 
Swift :: Swift Overriding Methods and Properties 
Swift :: AMAZONCONNECT 
Swift :: swiftUI parse json from url 
Swift :: swift hashable 
Ruby :: rails api only with postgress and rspec 
Ruby :: rails get current database name 
Ruby :: ruby delete folder recursively 
Ruby :: ruby exponent 
Ruby :: function is uninitialized constant ruby 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =