UNPKG

ethstorage-sdk-ts

Version:

eip-4844 blobs upload sdk from ethstorage-sdk

39 lines (38 loc) 1.34 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.EthStorage = void 0; const fs_1 = __importDefault(require("fs")); const ethstorage_1 = require("./ethstorage"); class EthStorage extends ethstorage_1.BaseEthStorage { getFileInfo(filePath) { console.log("getFileInfo", filePath); const fileStat = fs_1.default.statSync(filePath); if (fileStat.isFile()) { const name = filePath.substring(filePath.lastIndexOf("/") + 1); return { isFile: true, isDirectory: false, name: name, size: fileStat.size, path: filePath, }; } return { isFile: false, isDirectory: fileStat.isDirectory(), }; } async getFileChunk(filePath, fileSize, start, end) { end = end > fileSize ? fileSize : end; const length = end - start; const buf = Buffer.alloc(length); const fd = fs_1.default.openSync(filePath, "r"); fs_1.default.readSync(fd, buf, 0, length, start); fs_1.default.closeSync(fd); return buf; } } exports.EthStorage = EthStorage;