shareFile()

Syntax

shareFile(
  toPublicKey: string,
  chosenId: string,
  fileType: UploadType
)

This method allows sharing a file.

Note: can't share files with yourself

Parameters

fileType has two values as below:

const FILE_TYPE = ["UNENCRYPTED", "ENCRYPT"];

Example

  import { shareFile } from "@eueno/lib-browser";

  const handleShareFile = async () => {
    let toPublicKey = "04f0fa76...b9ebc5b6";
    let chosenId = "224"; 
    let fileType = "ENCRYPT";
    
    try {
      const res = await shareFile(toPublicKey, chosenId, fileType);
      console.log(res);
    } catch (error) {
      console.log(error);
    }
  };

Response of example:

{
    "msg": "success",
    "data": {
        "id": "176",
        "ownerAddress": "0x8bf5bf899059cde0e9770f4740fa9c8f6f5d07f9",
        "fileId": "1523",
        "projectId": "211",
        "sharedUserAddress": "0xf069ff728e9fc85d81163269f3b04ef5cf387f15",
        "encryptedKey": "bc2750381871f1f44ac6a70df5d7baab0fa42062863ec1b241e63ff651898e000b1964a8543081fd4c2f62aa358be6947cffe092b4a42ff7a002295121e9ec1ca9f4927560559b2cd6a6efcf427f432382647f27eb3759f3ca74f6ded610086fe08abce8e6aaefe30ec426194efe8252@@044020b145c7ae4e5d36a897a912a4d2100f2eecd96ec9f8ffeea6eaf64fd10a7caf513ad697c6068dd345543496d987a0baf5839561011391e606fd3610c6a2e2@@1e39dfb531e23fb0c00246e3715738c5@@4f2975507a07a21bc11e527904a969154b731dbd3a9ab8243268d7289d4b4091",
        "relFolderPath": "",
        "createdAt": "2023-04-30T03:28:05.489Z",
        "updatedAt": "2023-04-30T03:28:05.489Z"
    }
}

Last updated