-
Notifications
You must be signed in to change notification settings - Fork 0
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
e0f9dfc
commit 9b03238
Showing
4 changed files
with
30 additions
and
17 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
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
20 changes: 20 additions & 0 deletions
20
retrofitLib/src/main/java/com/zeropercenthappy/retrofitutil/ext/FileExt.kt
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,20 @@ | ||
package com.zeropercenthappy.retrofitutil.ext | ||
|
||
import android.webkit.MimeTypeMap | ||
import java.io.File | ||
import java.io.InputStream | ||
|
||
val File.mimeType: String | ||
get() = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension) ?: "" | ||
|
||
fun File.writeFromInputStream(inputStream: InputStream): Boolean { | ||
return try { | ||
this.outputStream().buffered().use { output -> | ||
inputStream.copyTo(output) | ||
} | ||
true | ||
} catch (e: Exception) { | ||
e.printStackTrace() | ||
false | ||
} | ||
} |
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