测试已测试 | ✓ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2016 年 12 月 |
SwiftSwift 版本 | 3.0.1 |
SPM支持 SPM | ✗ |
由 Jason 维护。
iPic 可在 macOS 上自动上传图片并保存 Markdown 链接。
Command + U
使用服务上传图片。Shift + Command + U
上传复制的图片。下载 iPic 尝试一下。
iPic 打开了上传图片的能力。这意味着如果您的 App 也需要上传图片,无需从头构建。只需使用 iPicUploader,您的 App 也可以将图片上传到 Imgur、Flickr、Amazon S3 和其他图床。
上传图片文件
let imageFilePath = "/Path/to/the/pic.jpg"
iPic.uploadImage(imageFilePath, handler: { (imageLink, error) in
if let imageLink = imageLink {
// Image uploaded
} else if let error = error {
// Some error happened
}
})
上传图片数据
let imageFilePath = "/Path/to/the/pic.jpg"
let imageURL = URL(fileURLWithPath: imageFilePath)
let imageData = try! Data(contentsOf: imageURL)
iPic.uploadImage(imageData, handler: { (imageLink, error) in
if let imageLink = imageLink {
// Image uploaded
} else if let error = error {
// Some error happened
}
})
上传 NSImage
let imageFilePath = "/Path/to/the/pic.jpg"
let image = NSImage(contentsOfFile: imageFilePath)
iPic.uploadImage(image, handler: { (imageLink, error) in
if let imageLink = imageLink {
// Image uploaded
} else if let error = error {
// Some error happened
}
})
iPicUploader 还包括一个完整示例。您将感到很容易开始。要运行示例项目,只需克隆当前仓库并打开 iPicUploader.xcworkspace。
注意
现在,让我们看看示例如何上传图片。
如您所见,iPicUploader 支持一次性上传多个图片。
除了复制图片文件外,您还可以复制其他应用程序中的图片以上传。
在这里展示您使用iPicUploader的app将非常棒。欢迎提交拉取请求 :)
因为iPic运行于macOS 10.11及以上版本,所以iPicUploader也需要macOS 10.11及以上。
iPicUploader可以通过CocoaPods获取。要安装它,只需将以下行添加到您的Podfile中
pod "iPicUploader"
iPicUploader受MIT许可证保护。