Created
April 7, 2019 09:39
-
-
Save pahill/055f6056e0f8b6425b69d22b36c96cad to your computer and use it in GitHub Desktop.
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
override suspend fun createInspiration( | |
userId: Long, | |
fileExtension: String, | |
inputStream: ByteArrayInputStream | |
): Inspiration? { | |
return dbQuery { | |
//Save the file | |
val inspirationImage = File("$IMAGE_DIR/${UUID.randomUUID()}.$fileExtension") | |
inspirationImage.writeBytes(inputStream.readBytes()) | |
//Insert the inspiration | |
val id = Inspirations.insert { | |
it[Inspirations.userId] = userId | |
it[Inspirations.fileUrl] = inspirationImage.toURI().toURL().toExternalForm() | |
it[Inspirations.generatedDate] = Date().time | |
} get Inspirations.id | |
id?.let { syncFindInspirationById(it) } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment