Eueno
  • EUENO – Decentralized Encrypting Blockchain Oracles for Web3
    • Litepaper
    • Use Cases
  • Get Started
    • Prerequisites
    • Buckets
      • Create a bucket
      • Delete a bucket
    • Files
      • Upload a file
      • View a file
      • Delete a file
      • Share a file
  • Pricing
  • Eueno libraries
    • @eueno/lib-browser
      • Installation
      • Setup
      • Create key (generate a key for encrypting the file(s))
      • login()
      • useEuenoContext()
      • getUserInfo()
      • updateUserInfo()
      • createProject()
      • getProjectInfo()
      • getProjects()
      • getFilesListByFolder()
      • deleteProject()
      • createFolder()
      • uploadFolder()
      • Get folder detail
      • deleteFolder()
      • uploadFile()
      • uploadFileWithSignedUrl()
      • getCid()
      • getFileById()
      • getFileListById()
      • Get file detail
        • getDetailFile()
        • getDetailUnencryptedFile()
        • getDetailEncryptedFile()
      • getDetailMultiEncryptedFiles()
      • deleteFile()
      • shareFile()
      • shareMultiFile()
      • deleteSharePermission()
      • getShareList()
      • getShareListToMe ()
    • @eueno/lib-node
      • Create eueno client
      • Create project key
      • Create project
      • Upload file
      • Upload folder
      • Get file
      • Get list file
      • Share file
      • Get shared files
      • Create folder
      • Create Account
      • Decrypt Get Key Aes
      • Decrypt File by Key Aes
  • Policies
    • Privacy Policy
    • Terms of Service
Powered by GitBook
On this page
  • Syntax
  • Parameters
  • Example
  1. Eueno libraries
  2. @eueno/lib-browser

uploadFile()

Syntax

uploadFile(token: string, publicKey: string, options: UploadFileOptions)

The method used to upload files in Eueno. We have two types to upload are encrypted and unencrypted.

Parameters

Name
Type
Required
Description

token

string

Yes

The authentication token response from Eueno API when login. After login, this token was saved in local storage with the name “eueno-token".

publicKey

string

Yes

The public key of user.

options

UploadFileOptions

Yes

Type UploadFileOptions has the structure like this:

interface UploadOptions { 
 file: File;
 path: string[]; // Path file
 projectId: string;
 uploadType: UploadType;
 inFolder: boolean;
 exportedKey?: string; // Need if encrypt
 onUploadProgress: () => void; // Progress upload file,
 account: string;
}

export interface UploadFileOptions extends UploadOptions {
 isLargeFile?: boolean; // file's size > 20MB
 chunkSize?: number; // size of each chunk part, recommend 5MB
 uploadUrl?: UploadUrl; // must be ignored when uploading a single file
 callback?: (
   bufferData: BufferData,
   webseed: string[],
   account: string
 ) => void; // callback must be ignored when uploading a single file
}

Example

Example using ReactJS with Axios. Assuming that, you have a project named Project1 with id is “112”, inside this project we have Folder1, and inside Folder1 we have Folder2. So the path is like this: Project1/Folder1/Folder2. The code below shows how to upload a file by encrypt method in Folder2.

import {uploadFile as uploadFileLibrary} from "@eueno/lib-browser";

const uploadFile = async () => {
   const file = files[0];
   
   await uploadFileLibrary(token, publicKey, {
     exportedKey,
     file: file,
     path: [“112”, “Folder1”, “Folder2”],
     projectId: “112”,
     uploadType: "ENCRYPT",
     inFolder: false,
     account,
     onUploadProgress: (progressEvent, name) => {},
   });
 };

Response of example:

"data": {
        "id": "246203",
        "name": "images (3).jpeg",
        "url": "https://node1-gateway-ipfs.eueno.io/ipfs/Qmf7g...TYaLoA6pbJ3",
        "backupUrl": "https://node1-gateway-ipfs.eueno.io/ipfs/Qmf7gT1HkP...6pbJ3",
        "size": "5650",
        "mimeType": "image/jpeg",
        "method": "UN_ENCRYPT",
        "torrentSize": 4,
        "torrentUrl": "https://node1-gateway-ipfs.eueno.io/ipfs/QmbHg6cV...qmBNQz4U",
        "backupTorrentUrl": "https://node1-gateway-ipfs.eueno.io/ipfs/QmbHg6...qmBNQz4U",
        "encryptKey": null,
        "createdAt": "2023-04-12T09:19:46.721Z",
        "updatedAt": "2023-04-12T09:19:46.938Z"
}
PreviousdeleteFolder()NextuploadFileWithSignedUrl()

Last updated 1 year ago