diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt
index 766056a87..9db73c03e 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/ImageUploader.kt
@@ -43,6 +43,8 @@ object ImageUploader {
NostrImgServer()
} else if (server == ServersAvailable.NOSTR_BUILD) {
NostrBuildServer()
+ } else if (server == ServersAvailable.NOSTRFILES_DEV) {
+ NostrfilesDevServer()
} else {
ImgurServer()
}
@@ -62,7 +64,7 @@ object ImageUploader {
onSuccess: (String, String?) -> Unit,
onError: (Throwable) -> Unit
) {
- val category = contentType?.toMediaType()?.toString()?.split("/")?.get(0) ?: "image"
+ var category = contentType?.toMediaType()?.toString()?.split("/")?.get(0) ?: "image"
val fileName = randomChars()
val extension = contentType?.let { MimeTypeMap.getSingleton().getExtensionFromMimeType(it) } ?: ""
@@ -71,12 +73,17 @@ object ImageUploader {
val requestBody: RequestBody
val requestBuilder = Request.Builder()
- if (serverType == ServersAvailable.NOSTR_BUILD) {
- requestBuilder.addHeader("Content-Type", "multipart/form-data")
+ if (serverType == ServersAvailable.NOSTR_BUILD || serverType == ServersAvailable.NOSTRFILES_DEV) {
+ if (serverType == ServersAvailable.NOSTR_BUILD) {
+ requestBuilder.addHeader("Content-Type", "multipart/form-data")
+ category = "fileToUpload"
+ } else if (serverType == ServersAvailable.NOSTRFILES_DEV) {
+ category = "file"
+ }
requestBody = MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart(
- "fileToUpload",
+ category,
"$fileName.$extension",
file.asRequestBody(contentType?.toMediaType())
@@ -212,3 +219,14 @@ class NostrBuildServer : FileServer() {
override fun clientID() = null
}
+
+class NostrfilesDevServer : FileServer() {
+ override fun postUrl(contentType: String?) = "https://nostrfiles.dev/upload_image"
+ override fun parseUrlFromSucess(body: String): String? {
+ val tree = jacksonObjectMapper().readTree(body)
+ val url = tree?.get("url")?.asText()
+ return url
+ }
+
+ override fun clientID() = null
+}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt
index ac812b2c2..edc977ec5 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaModel.kt
@@ -46,6 +46,8 @@ open class NewMediaModel : ViewModel() {
selectedServer = ServersAvailable.NOSTRIMG_NIP_94
} else if (selectedServer == ServersAvailable.NOSTR_BUILD) {
selectedServer = ServersAvailable.NOSTR_BUILD_NIP_94
+ } else if (selectedServer == ServersAvailable.NOSTRFILES_DEV) {
+ selectedServer = ServersAvailable.NOSTRFILES_DEV_NIP_94
}
}
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt
index c1489f126..c56bcbdfb 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewMediaView.kt
@@ -109,6 +109,14 @@ fun NewMediaView(uri: Uri, onClose: () -> Unit, postViewModel: NewMediaModel, ac
}
}
+fun isNIP94Server(selectedServer: ServersAvailable?): Boolean {
+ return selectedServer == ServersAvailable.NOSTRIMG_NIP_94 ||
+ selectedServer == ServersAvailable.IMGUR_NIP_94 ||
+ selectedServer == ServersAvailable.NOSTR_BUILD_NIP_94 ||
+ selectedServer == ServersAvailable.NOSTRFILES_DEV_NIP_94
+}
+
+
@Composable
fun ImageVideoPost(postViewModel: NewMediaModel, acc: Account) {
val scope = rememberCoroutineScope()
@@ -191,9 +199,7 @@ fun ImageVideoPost(postViewModel: NewMediaModel, acc: Account) {
)
}
- if (postViewModel.selectedServer == ServersAvailable.NOSTRIMG_NIP_94 ||
- postViewModel.selectedServer == ServersAvailable.IMGUR_NIP_94 ||
- postViewModel.selectedServer == ServersAvailable.NOSTR_BUILD_NIP_94 ||
+ if (isNIP94Server(postViewModel.selectedServer) ||
postViewModel.selectedServer == ServersAvailable.NIP95
) {
Row(
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
index 370bf8728..620e393c5 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
@@ -588,9 +588,11 @@ enum class ServersAvailable {
IMGUR,
NOSTR_BUILD,
NOSTRIMG,
+ NOSTRFILES_DEV,
IMGUR_NIP_94,
NOSTRIMG_NIP_94,
NOSTR_BUILD_NIP_94,
+ NOSTRFILES_DEV_NIP_94,
NIP95
}
@@ -612,9 +614,11 @@ fun ImageVideoDescription(
Triple(ServersAvailable.IMGUR, stringResource(id = R.string.upload_server_imgur), stringResource(id = R.string.upload_server_imgur_explainer)),
Triple(ServersAvailable.NOSTRIMG, stringResource(id = R.string.upload_server_nostrimg), stringResource(id = R.string.upload_server_nostrimg_explainer)),
Triple(ServersAvailable.NOSTR_BUILD, stringResource(id = R.string.upload_server_nostrbuild), stringResource(id = R.string.upload_server_nostrbuild_explainer)),
+ Triple(ServersAvailable.NOSTRFILES_DEV, stringResource(id = R.string.upload_server_nostrfilesdev), stringResource(id = R.string.upload_server_nostrfilesdev_explainer)),
Triple(ServersAvailable.IMGUR_NIP_94, stringResource(id = R.string.upload_server_imgur_nip94), stringResource(id = R.string.upload_server_imgur_nip94_explainer)),
Triple(ServersAvailable.NOSTRIMG_NIP_94, stringResource(id = R.string.upload_server_nostrimg_nip94), stringResource(id = R.string.upload_server_nostrimg_nip94_explainer)),
Triple(ServersAvailable.NOSTR_BUILD_NIP_94, stringResource(id = R.string.upload_server_nostrbuild_nip94), stringResource(id = R.string.upload_server_nostrbuild_nip94_explainer)),
+ Triple(ServersAvailable.NOSTRFILES_DEV_NIP_94, stringResource(id = R.string.upload_server_nostrfilesdev_nip94), stringResource(id = R.string.upload_server_nostrfilesdev_nip94_explainer)),
Triple(ServersAvailable.NIP95, stringResource(id = R.string.upload_server_relays_nip95), stringResource(id = R.string.upload_server_relays_nip95_explainer))
)
@@ -742,9 +746,7 @@ fun ImageVideoDescription(
)
}
- if (selectedServer == ServersAvailable.NOSTRIMG_NIP_94 ||
- selectedServer == ServersAvailable.IMGUR_NIP_94 ||
- selectedServer == ServersAvailable.NOSTR_BUILD_NIP_94 ||
+ if (isNIP94Server(selectedServer) ||
selectedServer == ServersAvailable.NIP95
) {
Row(
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
index 42590becc..8ea846834 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
@@ -148,7 +148,7 @@ open class NewPostViewModel : ViewModel() {
context = context,
contentResolver = contentResolver,
onSuccess = { imageUrl, mimeType ->
- if (server == ServersAvailable.IMGUR_NIP_94 || server == ServersAvailable.NOSTRIMG_NIP_94 || server == ServersAvailable.NOSTR_BUILD_NIP_94) {
+ if (isNIP94Server(server)) {
createNIP94Record(imageUrl, mimeType, description)
} else {
isUploadingImage = false
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 143f5b6b1..703bb8e12 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -336,6 +336,10 @@
nostr.build - trusted
Nostr.build can modify the file
+ nostrfiles.dev - trusted
+ Nostrfiles.dev can modify the file
+
+
Verifiable Imgur (NIP-94)
Checks if Imgur modified the file. New NIP: other clients might not see it
@@ -345,6 +349,10 @@
Verifiable Nostr.build (NIP-94)
Checks if Nostr.build modified the file. New NIP: other clients might not see it
+ Verifiable Nostrfiles.dev (NIP-94)
+ Checks if Nostrfiles.dev modified the file. New NIP: other clients might not see it
+
+
Your relays (NIP-95)
Files are hosted by your relays. New NIP: check if they support