-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
871beac
commit 42e094f
Showing
28 changed files
with
859 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
|
||
![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-apple.svg?color=green&style=flat-square) | ||
![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.svg?style=flat-square) | ||
![Version](https://img.shields.io/badge/api%20version-0.14.0-blue.svg?style=flat-square) | ||
![Version](https://img.shields.io/badge/api%20version-0.15.0-blue.svg?style=flat-square) | ||
[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator) | ||
[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee&label=twitter&style=flat-square)](https://twitter.com/appwrite) | ||
[![Discord](https://img.shields.io/discord/564160730845151244?label=discord&style=flat-square)](https://appwrite.io/discord) | ||
|
||
**This SDK is compatible with Appwrite server version 0.14.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).** | ||
**This SDK is compatible with Appwrite server version 0.15.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).** | ||
|
||
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs) | ||
|
||
|
@@ -31,7 +31,7 @@ Add the package to your `Package.swift` dependencies: | |
|
||
```swift | ||
dependencies: [ | ||
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "0.5.0"), | ||
.package(url: "[email protected]:appwrite/sdk-for-apple.git", from: "0.6.0"), | ||
], | ||
``` | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
import Foundation | ||
|
||
fileprivate let DEFAULT_MIME_TYPE = "application/octet-stream" | ||
|
||
fileprivate let mimeTypes = [ | ||
"md": "text/markdown", | ||
"html": "text/html", | ||
"htm": "text/html", | ||
"shtml": "text/html", | ||
"css": "text/css", | ||
"xml": "text/xml", | ||
"gif": "image/gif", | ||
"jpeg": "image/jpeg", | ||
"jpg": "image/jpeg", | ||
"js": "application/javascript", | ||
"atom": "application/atom+xml", | ||
"rss": "application/rss+xml", | ||
"mml": "text/mathml", | ||
"txt": "text/plain", | ||
"jad": "text/vnd.sun.j2me.app-descriptor", | ||
"wml": "text/vnd.wap.wml", | ||
"htc": "text/x-component", | ||
"png": "image/png", | ||
"tif": "image/tiff", | ||
"tiff": "image/tiff", | ||
"wbmp": "image/vnd.wap.wbmp", | ||
"ico": "image/x-icon", | ||
"jng": "image/x-jng", | ||
"bmp": "image/x-ms-bmp", | ||
"svg": "image/svg+xml", | ||
"svgz": "image/svg+xml", | ||
"webp": "image/webp", | ||
"woff": "application/font-woff", | ||
"jar": "application/java-archive", | ||
"war": "application/java-archive", | ||
"ear": "application/java-archive", | ||
"json": "application/json", | ||
"hqx": "application/mac-binhex40", | ||
"doc": "application/msword", | ||
"pdf": "application/pdf", | ||
"ps": "application/postscript", | ||
"eps": "application/postscript", | ||
"ai": "application/postscript", | ||
"rtf": "application/rtf", | ||
"m3u8": "application/vnd.apple.mpegurl", | ||
"xls": "application/vnd.ms-excel", | ||
"eot": "application/vnd.ms-fontobject", | ||
"ppt": "application/vnd.ms-powerpoint", | ||
"wmlc": "application/vnd.wap.wmlc", | ||
"kml": "application/vnd.google-earth.kml+xml", | ||
"kmz": "application/vnd.google-earth.kmz", | ||
"7z": "application/x-7z-compressed", | ||
"cco": "application/x-cocoa", | ||
"jardiff": "application/x-java-archive-diff", | ||
"jnlp": "application/x-java-jnlp-file", | ||
"run": "application/x-makeself", | ||
"pl": "application/x-perl", | ||
"pm": "application/x-perl", | ||
"prc": "application/x-pilot", | ||
"pdb": "application/x-pilot", | ||
"rar": "application/x-rar-compressed", | ||
"rpm": "application/x-redhat-package-manager", | ||
"sea": "application/x-sea", | ||
"swf": "application/x-shockwave-flash", | ||
"sit": "application/x-stuffit", | ||
"tcl": "application/x-tcl", | ||
"tk": "application/x-tcl", | ||
"der": "application/x-x509-ca-cert", | ||
"pem": "application/x-x509-ca-cert", | ||
"crt": "application/x-x509-ca-cert", | ||
"xpi": "application/x-xpinstall", | ||
"xhtml": "application/xhtml+xml", | ||
"xspf": "application/xspf+xml", | ||
"zip": "application/zip", | ||
"bin": "application/octet-stream", | ||
"exe": "application/octet-stream", | ||
"dll": "application/octet-stream", | ||
"deb": "application/octet-stream", | ||
"dmg": "application/octet-stream", | ||
"iso": "application/octet-stream", | ||
"img": "application/octet-stream", | ||
"msi": "application/octet-stream", | ||
"msp": "application/octet-stream", | ||
"msm": "application/octet-stream", | ||
"docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", | ||
"xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||
"pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation", | ||
"mid": "audio/midi", | ||
"midi": "audio/midi", | ||
"kar": "audio/midi", | ||
"mp3": "audio/mpeg", | ||
"ogg": "audio/ogg", | ||
"m4a": "audio/x-m4a", | ||
"ra": "audio/x-realaudio", | ||
"3gpp": "video/3gpp", | ||
"3gp": "video/3gpp", | ||
"ts": "video/mp2t", | ||
"mp4": "video/mp4", | ||
"mpeg": "video/mpeg", | ||
"mpg": "video/mpeg", | ||
"mov": "video/quicktime", | ||
"webm": "video/webm", | ||
"flv": "video/x-flv", | ||
"m4v": "video/x-m4v", | ||
"mng": "video/x-mng", | ||
"asx": "video/x-ms-asf", | ||
"asf": "video/x-ms-asf", | ||
"wmv": "video/x-ms-wmv", | ||
"avi": "video/x-msvideo" | ||
] | ||
|
||
fileprivate func mimeFromExt(ext: String?) -> String { | ||
let lower: String = ext!.lowercased() | ||
if ext != nil && mimeTypes.contains(where: { $0.0 == lower }) { | ||
return mimeTypes[lower]! | ||
} | ||
return DEFAULT_MIME_TYPE | ||
} | ||
|
||
extension NSString { | ||
public func mimeType() -> String { | ||
return mimeFromExt(ext: self.pathExtension) | ||
} | ||
} | ||
|
||
extension String { | ||
public func mimeType() -> String { | ||
return (self as NSString).mimeType() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,41 @@ | ||
import Foundation | ||
import NIO | ||
|
||
open class File { | ||
open class InputFile { | ||
|
||
public let name: String | ||
public var buffer: ByteBuffer | ||
public var path: String = "" | ||
public var filename: String = "" | ||
public var mimeType: String = "" | ||
public var sourceType: String = "" | ||
public var data: Any? = nil | ||
|
||
public init(name: String, buffer: ByteBuffer) { | ||
self.name = name | ||
self.buffer = buffer | ||
internal init() { | ||
} | ||
|
||
public static func fromPath(_ path: String) -> InputFile { | ||
let instance = InputFile() | ||
instance.path = path | ||
instance.filename = URL(fileURLWithPath: path, isDirectory: false).lastPathComponent | ||
instance.mimeType = path.mimeType() | ||
instance.sourceType = "path" | ||
return instance | ||
} | ||
|
||
public static func fromData(_ data: Data, filename: String, mimeType: String) -> InputFile { | ||
let instance = InputFile() | ||
instance.filename = filename | ||
instance.mimeType = mimeType | ||
instance.sourceType = "data" | ||
instance.data = data | ||
return instance | ||
} | ||
|
||
public static func fromBuffer(_ buffer: ByteBuffer, filename: String, mimeType: String) -> InputFile { | ||
let instance = InputFile() | ||
instance.filename = filename | ||
instance.mimeType = mimeType | ||
instance.sourceType = "buffer" | ||
instance.data = buffer | ||
return instance | ||
} | ||
} |
Oops, something went wrong.