Files
andros 225e9a58ec Add GitHub, Codeberg, WebDAV upload backends; fix vfile download bug
- New FeedUploader protocol with VFileUploader, GitHubUploader, CodebergUploader, WebDAVUploader
- GitHub/Codeberg: fetch current file SHA via API before PUT (handles create + update)
- WebDAV: HTTP PUT with optional Basic Auth
- ComposeViewModel: always downloads from publicFeedURL (vfile token URL is upload-only, GET returns 404)
- SettingsViewModel: per-method config fields + derived public URL hints for GitHub/Codeberg
- SettingsView: method picker with conditional sections; VFile shows signup link; SFTP/FTP excluded (no native iOS support)
2026-04-19 11:13:04 +02:00

33 lines
974 B
Swift

import Foundation
/// Protocol all upload backends conform to.
public protocol FeedUploader: Sendable {
/// Uploads the full updated `social.org` content to the remote host.
func upload(content: String) async throws
}
public enum UploadError: Error, Sendable {
case uploadFailed(statusCode: Int)
case networkError(underlying: String)
case invalidConfiguration(String)
case fileNotFound
}
extension UploadError: LocalizedError {
public var errorDescription: String? {
switch self {
case .uploadFailed(let code): return "Upload failed with HTTP \(code)."
case .networkError(let msg): return "Network error: \(msg)"
case .invalidConfiguration(let msg): return "Upload not configured: \(msg)"
case .fileNotFound: return "Remote file not found."
}
}
}
public enum UploadMethod: String, CaseIterable, Sendable {
case vfile
case github
case codeberg
case webdav
}