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 :: add months to date swift 
Swift :: swift infinite while loop 
Swift :: symfony swiftmailer 
Swift :: Prime number or not program in swift basic programs 
Swift :: swift create an empty array 
Swift :: make optional protocol swift 
Swift :: how to dismiss a view when touch up inside swift 
Swift :: timer in swift stack overflow 
Swift :: Swift Markup in Xcode 11 
Swift :: swift extension Array of element 
Swift :: uitextfield set max length 
Swift :: swiftui hidden 
Swift :: swift uilabel font bold 
Swift :: two integer variable in swift 
Swift :: convert nscfstring to dictionary swift 
Swift :: swift combine 2 sets 
Swift :: why launch screen changes appear after 1 day in ios swift 
Swift :: free robux codes 
Swift :: swift - salesforce chat only 
Swift :: xcode button center text 
Swift :: Swift self property 
Swift :: Swift Explicitly declaring an unwrapped optional 
Swift :: Trailing Closure Swift 
Swift :: convert dictionary to data 
Swift :: Swift Function Overloading 
Swift :: enum Associated Values Swift 
Ruby :: see all rails routes in browser 
Ruby :: embedded ruby tag 
Ruby :: integer to string ruby 
Ruby :: ruby loop through array from last item backwards 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =