bykof / cordova-plugin-webserver

A webserver plugin for cordova
Other
124 stars 49 forks source link

Binary Responses #68

Open ecc521 opened 3 years ago

ecc521 commented 3 years ago

Is there any way to send binary data (like images) using this plugin? It appears that only text is supported (sending an arrayBuffer resulted in sigterm)

edsonlb commented 2 weeks ago

I'm in 2024, and have the same question. I tried "reader.readAsArrayBuffer" and also "reader.readAsDataURL" as base64, but none worked.

Did you had any success?

edsonlb commented 2 weeks ago

Made this one and worked! window.resolveLocalFileSystemURL(fullPath, function(entry) { var contentType = getContentType(fullPath); webserver.sendResponse( request.requestId, { status: 200, path: entry.toURL().replace(/^file:\/\//, ''), // REMOVING FILE:// FROM PATH! headers: { 'Content-Type': contentType } } ); }