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
@Database(entities = arrayOf(Note::class, User::class), version = 1) | |
@TypeConverters(Converters::class) | |
abstract class AppDatabse : RoomDatabase() { | |
abstract fun userDAO(): UserDAO | |
abstract fun noteDAO(): NoteDAO | |
} |
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
func requestWith(endUrl: String, imageData: Data?, parameters: [String : Any], onCompletion: ((JSON?) -> Void)? = nil, onError: ((Error?) -> Void)? = nil){ | |
let url = "http://google.com" /* your API url */ | |
let headers: HTTPHeaders = [ | |
/* "Authorization": "your_access_token", in case you need authorization header */ | |
"Content-type": "multipart/form-data" | |
] | |
Alamofire.upload(multipartFormData: { (multipartFormData) in |
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
// Swift4 | |
let image = UIImage(named: "sample") | |
let data = image?.pngData() | |
let data = image?.jpegData(compressionQuality: 0.9) | |
let uiImage: UIImage = UIImage(data: imageData) | |
// deprecated | |
// var imageData: Data = UIImagePNGRepresentation(image) |
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
#!/bin/sh | |
# Install Java-8 | |
#sudo add-apt-repository ppa:webupd8team/java -y | |
#sudo apt-get update | |
#echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections | |
#echo oracle-java9-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections | |
#sudo apt-get install oracle-java8-installer oracle-java9-installer oracle-java9-set-default | |
sudo apt-get install openjdk-8-jdk |