func getBodyLength()

in Sources/OSS/Types/ByteStream.swift [36:51]


    func getBodyLength() throws -> UInt64? {
        switch self {
        case .none:
            return 0
        case let .data(d):
            return UInt64(d.count)
        /// Body data is read from the given file URL
        case let .file(fileURL):
            guard let s = try FileManager.default.attributesOfItem(atPath: fileURL.path)[.size] as? NSNumber else {
                throw _Error.fileForBodyNotFound
            }
            return s.uint64Value
        case .stream:
            return nil
        }
    }