textiot
Version:
A framework for building web and native (IoT) Dapps on the IPFS network
48 lines (47 loc) • 1.72 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const api_1 = require("../core/api");
/**
* File is an API module for requesting information about a Textile File
*
* @extends {API}
*/
class File extends api_1.API {
/**
*
* Get raw data for a File
*
* @param hash The hash for the requested file
* @returns Raw data
*/
content(hash) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.sendGet(`file/${hash}/content`);
// @todo: change this (back) to `response.arrayBuffer()`?
return response.blob();
});
}
/**
*
* Get metadata for a File
*
* @param target The hash for the target file
* @returns Metadata object
*/
meta(target) {
return __awaiter(this, void 0, void 0, function* () {
const response = yield this.sendGet(`file/${target}/meta`);
return response.json();
});
}
}
exports.default = File;
;