Skip to content

Commit

Permalink
feat: use KFS interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Parodi committed Oct 10, 2022
1 parent cbd73c0 commit fd1a851
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/files/files.controller.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fileUpload from 'express-fileupload';
import {StorageOperationController} from '../hyperledger/StorageOperationController';
import ipfsService from '../ipfs/ipfs.service';
import {MFSEntry} from 'ipfs-core-types/src/files';
import {KFSEntry} from './files.interfaces';

class FilesController {
async createFile(userId: string, file: fileUpload.UploadedFile) {
Expand All @@ -11,13 +11,13 @@ class FilesController {
try {
return await ipfsService
.createFile(userId, file)
.then((files: MFSEntry[]) => {
.then((files: KFSEntry[]) => {
console.log('[DEBUG] files.controller - createFile: files', files);

files.forEach((file: MFSEntry) => {
files.forEach((file: KFSEntry) => {
new StorageOperationController().createFileOperation(
userId,
file.cid.toString(),
file.id,
'WRITE'
);
});
Expand All @@ -36,13 +36,13 @@ class FilesController {
`[INFO] files.controller - listFiles: Listing files for userId ${userId}`
);
try {
return await ipfsService.listFiles().then((files: MFSEntry[]) => {
return await ipfsService.listFiles().then((files: KFSEntry[]) => {
console.log('[DEBUG] files.controller - listFiles: files', files);

files.forEach((file: MFSEntry) => {
files.forEach((file: KFSEntry) => {
new StorageOperationController().createFileOperation(
userId,
file.cid.toString(),
file.id,
'READ'
);
});
Expand Down
4 changes: 2 additions & 2 deletions src/ipfs/ipfs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class IPFSService {
public async createFile(
userId: string,
file: UploadedFile
): Promise<MFSEntry[]> {
): Promise<KFSEntry[]> {
const filePath = `/${file.name}`;
console.log('[DEBUG] IPFSService - createFile', userId, file);

Expand Down Expand Up @@ -83,7 +83,7 @@ class IPFSService {
* @returns
*/
public async updateFile(file: File) {
const result: Array<MFSEntry> = [];
const result: Array<KFSEntry> = [];
// IPFSService.ipfsHttpClient.files.write('/' + file.name, file);
// result.push(...(await all(IPFSService.ipfsHttpClient.files.ls(file.name))));
return result;
Expand Down

0 comments on commit fd1a851

Please sign in to comment.