Skip to content

Instantly share code, notes, and snippets.

View feveral's full-sized avatar

steven feveral

  • Tsing Hua University
  • Taiwan
View GitHub Profile
@feveral
feveral / ImageUpload.swift
Last active October 20, 2020 15:39
ImageUpload.swift
class MImage: Codable {
/*
if your response json like:
{
"id": "5f6c2b39f1966ce3d67f52a7",
"url": "https://storage.googleapis.com/meme-image-dev/oESZ3bm36kHibV37whWofy.jpg",
"thumbnail_url": "https://storage.googleapis.com/meme-image-dev/iofTbsJis81RTTHgBKCG43.jpg",
"usage": 1,
"created_at": "2020-09-24T05:14:33.295Z"
}
import SwiftUI
import Photos
public struct ImagePicker: UIViewControllerRepresentable {
private let sourceType: UIImagePickerController.SourceType
private let onImagePicked: (Data) -> Void
@Environment(\.presentationMode) private var presentationMode
init(sourceType: UIImagePickerController.SourceType, onImagePicked: @escaping (Data) -> Void) {