1
Nativescriptフェッチモジュールで送信するのに適したBase64イメージを作成するにはどうすればよいですか?NativescriptイメージをBase64に転送してからPOSTをフェッチする
Nativescriptフェッチモジュールで送信するのに適したBase64イメージを作成するにはどうすればよいですか?NativescriptイメージをBase64に転送してからPOSTをフェッチする
はここでテストサーバーに私が探しているまさに
"use strict";
var imageSourceModule = require("image-source");
function navigatingTo(args) {
var page = args.object;
// using icon.png from the template app from res://icon
var imgSrc = imageSourceModule.fromResource("icon");
var imageAsBase64 = imgSrc.toBase64String("PNG");
fetch("https://httpbin.org/post", {
method: "POST",
headers: { "Content-Type": "application/octet-stream" },
body: imageAsBase64
}).then(function (r) { return r.json(); }).then(function (result) {
console.log("Base64String: " + result.data);
// for (var key in result) {
// if (result.hasOwnProperty(key)) {
// var element = object[result];
// console.log(key);
// console.log(element);
// console.log("------")
// }
// }
}, function (e) {
console.log("Error occurred " + e);
});
}
exports.navigatingTo = navigatingTo;
を使用して、あなたのケースのための基本的なデモです! – Terhoraj
あなたは大きな脂肪に値する...親指をつけてください! – Pytth
@Nick lliev、nativescriptでビットマップをBase64に変換する方法はありますか? –