shareMultiFile()

Syntax

shareMultiFile(
  toPublicKey: string,
  fileList: Array<FileForShare>,
  fileType: UploadType
)

This method allows sharing of multiple files which have the same file type (unencrypt or encrypt).

Note: can't share files with yourself

Parameters

fileType has two values as below:

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

Type FileForShare has the structure like this:

interface FileForShare {
  fileId: string; // file ID
  encryptKey: string; // encrypt key of file
}

Example

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

  const handleShareFile = async () => {
    const toPublicKey = "04f0fa76...b9ebc5b6";
    const listFileForShare = [
      {
        encryptedKey: "54bac30c19d54b...d750a4bbd6e9d",
        fileId: "19864",
        sharedUserAddress: "0xac7875c...8690cc7"
      },
      {
        encryptedKey: "c2e8f5f76d...f9c29c982e32312",
        fileId: "19861",
        sharedUserAddress: "0xac7875c...8690cc7"
      },
      {
        encryptedKey: "9a2dfa369...8d816db2fe74b2",
        fileId: "19860",
        sharedUserAddress: "0xac7875c...8690cc7"
      },
    ]
    const fileType = "ENCRYPT";
    
    try {
      const res = await shareMultiFile(toPublicKey, listFileForShare, fileType);
      console.log(res);
    } catch (error) {
      console.log(error);
    }
  };

Response of example:

{
    "msg": "success",
    "data": [
        {
            "id": "321",
            "ownerAddress": "0xabe30d9feeac7484b4e0aba42dbe5857d4840971",
            "fileId": "19864",
            "projectId": "373",
            "sharedUserAddress": "0xac7875c2c65abbb447b03c6c848e1e4ec8690cc7",
            "encryptedKey": "61e528305006ce45876976906cdf3c3fc183e7bb2c6a5a8f8ee522634ab542cd9823d7aa8740fd9b4dcace5ad12fdd73b36b56a5e7816985dd8b8e6f2231a403bbe0af81598531222e76d840ae98aa067e6fbc061a2c4449fc902d186eb84882a62dc403c92a5d0c24a59833a33314b8@@04419c1e1f8e3e9d413e2ff6d773e74be4fcf8dbb31586fd3b6206a90a7a151c253880d9bf5b05517ececa856605b360a51e58642fddd39fe736ddf95b1be739be@@2cf041673d75cde76a1119f8691e222d@@81189018c27ab44c5e9f0d44a579e4c9b7e8b0eeb3556313bf17132c0e3db32f",
            "relFolderPath": "",
            "createdAt": "2023-05-25T10:39:11.171Z",
            "updatedAt": "2023-05-25T10:39:11.171Z"
        },
        {
            "id": "322",
            "ownerAddress": "0xabe30d9feeac7484b4e0aba42dbe5857d4840971",
            "fileId": "19861",
            "projectId": "373",
            "sharedUserAddress": "0xac7875c2c65abbb447b03c6c848e1e4ec8690cc7",
            "encryptedKey": "306e1abe6b4b3263943246c0dcf2415a8fce473707b1e3324a7dddab52ba7f7b079e5234bf73f53015b8d120fd2065d82bf3b3589b659350ca91e222966e4e3e9a9c8534f3868124c9f50e77292e7edb1c13a469fec4be10ee85682c2d41d9e2d5ce2712887b47bbd51f8dde2df59920@@046ed80d749598ac6b2b3f89b25ed045855e4c1e674bda1b7ebae06edef3f520873db9716d9eadd97e4830f4bd3a405ae22ff7174521981b902f846bd47983aae3@@6fac4f29315e43d8e8ae1f7abfcfbf5b@@99d153b7fb3b1bc9c784849fdec1587a7a3e8e30712613934d732c3b771c0b24",
            "relFolderPath": "",
            "createdAt": "2023-05-25T10:40:07.038Z",
            "updatedAt": "2023-05-25T10:40:07.038Z"
        },
        {
            "id": "323",
            "ownerAddress": "0xabe30d9feeac7484b4e0aba42dbe5857d4840971",
            "fileId": "19860",
            "projectId": "373",
            "sharedUserAddress": "0xac7875c2c65abbb447b03c6c848e1e4ec8690cc7",
            "encryptedKey": "8a0b92d4fb18bdc6260699ba2031734f7e9167751fc61810fff9102d2ce07f30a3444bc55633edc49beb3fa88aa68edd540ba5dfa9fa23a823de39779fccf8cbdcab85f681f9676340a0feb831d3d838d2ff4267ca3cdad272b32bf76a68a3451dc2abb2624ed37bfc093ccf20a33f38@@04d529ba9f55dbac2ecda9bf4db7bf17122cc58475e54dab5fa23a8050ea091283fcc76c79d3a7929872aa1d01d9e62071cf67d6b72afc06cf614e36b50d77762b@@957be98f7876551feaf3657eff7f6017@@a6370b01c925aae16e3877a39030abad15d4f77626803af0f9bebd2e3a19da41",
            "relFolderPath": "",
            "createdAt": "2023-05-25T10:40:07.057Z",
            "updatedAt": "2023-05-25T10:40:07.057Z"
        }
    ]
}

Last updated