Skip to content

Build your personal knowledge base with Trilium Notes

fix uploading binary data through ETAPI, closes #2667

zadam9f337919229f
diff --git a/src/app.js b/src/app.js
index 6ba7c1b782..b530ca7e47 100644
--- a/src/app.js
+++ b/src/app.js
@@ -25,6 +25,7 @@ app.use(helmet({
app.use(express.text({limit: '500mb'}));
app.use(express.json({limit: '500mb'}));
+app.use(express.raw({limit: '500mb'}));
app.use(express.urlencoded({extended: false}));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
diff --git a/test-etapi/put-note-content-binary.http b/test-etapi/put-note-content-binary.http
new file mode 100644
index 0000000000..545b3c111f
--- /dev/null
+++ b/test-etapi/put-note-content-binary.http
@@ -0,0 +1,25 @@
+POST {{triliumHost}}/etapi/create-note
+Authorization: {{authToken}}
+Content-Type: application/json
+
+{
+ "parentNoteId": "root",
+ "title": "Hello",
+ "type": "image",
+ "mime": "image/png",
+ "content": ""
+}
+
+> {% client.global.set("createdNoteId", response.body.note.noteId); %}
+
+###
+
+PUT {{triliumHost}}/etapi/notes/{{createdNoteId}}/content
+Authorization: {{authToken}}
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+
+< ../images/icon-color.png
+
+> {% client.assert(response.status === 204); %}
+
diff --git a/test-etapi/put-note-content.http b/test-etapi/put-note-content.http
index 10b7f1d214..66797c0dc9 100644
--- a/test-etapi/put-note-content.http
+++ b/test-etapi/put-note-content.http
@@ -20,6 +20,8 @@ Content-Type: text/plain
Changed content
+> {% client.assert(response.status === 200); %}
+
###
GET {{triliumHost}}/etapi/notes/{{createdNoteId}}/content