updateIndexFile
Update an existing file.
Usage
const encrypted = JSON.stringify({
text: true,
images: true,
videos: false,
});
await dataverseConnector.runOS({
method: SYSTEM_CALL.updateIndexFile,
params: {
fileId: indexFileId,
fileName: "post",
fileContent: {
modelVersion: "0.1.0",
text: "hello",
images: [
"https://bafkreib76wz6wewtkfmp5rhm3ep6tf4xjixvzzyh64nbyge5yhjno24yl4.ipfs.w3s.link",
],
videos: [],
createdAt: new Date().toISOString();,
updatedAt: new Date().toISOString();,
encrypted,
},
},
});
Parameters
fileId
:string
- id of the index file to be updatedfileContent
-object
- the new content of the file, fields under this object are decided by the data model you are using Here is an example - if your data model looks like this:
type post @createModel(accountRelation: LIST, description: "post") {
author: DID! @documentAccount
version: CommitID! @documentVersion
appVersion: String! @string(maxLength: 100)
text: String @string(maxLength: 300000000)
images: [String] @list(maxLength: 10000000) @string(maxLength: 2000000)
videos: [String] @list(maxLength: 10000000) @string(maxLength: 2000000)
options: String @string(maxLength: 300000000)
createdAt: DateTime!
updatedAt: DateTime!
}
your streamContent
shall be:
appVersion
-string
- the version of the app under which the stream will be createdtext
-string
- the text contentimages
-string[]
- the images urlvideos
-string[]
- the videos urlcreatedAt
-string
- the created time of the stream, generated bynew Date().toISOString()
updatedAt
-string
- the updated time of the stream, generated bynew Date().toISOString()
encrypted
-string
- JSON string of the fields to be encrypted or not, example:
JSON.stringify({
text: true,
images: true,
videos: false,
});
Returns
{
"fileContent": {
"content": {
"text": "hello",
"images": [
"https://bafkreib76wz6wewtkfmp5rhm3ep6tf4xjixvzzyh64nbyge5yhjno24yl4.ipfs.w3s.link"
],
"videos": [],
"createdAt": "2023-11-02T08:27:17.304Z",
"encrypted": "{\"text\":true,\"images\":true,\"videos\":false}",
"updatedAt": "2023-11-02T08:27:17.304Z",
"modelVersion": "0.0.1"
},
"file": {
"fileId": "kjzl6kcym7w8ya3kyamskljmo181t6z3vz6px0w90c76ea3m28g994t58341ijt",
"fsVersion": "0.11",
"contentId": "kjzl6kcym7w8y8wx1zuujmssq4wj6o6paynupzmidz7izcsiqwgpnt1uyo9lg2a",
"contentType": {
"resource": "CERAMIC",
"resourceId": "kjzl6hvfrbw6catek36h3pep09k9gymfnla9k6ojlgrmwjogvjqg8q3zpybl1yu"
},
"fileName": "update the file",
"fileType": 1,
"accessControl": {
"encryptionProvider": {
"protocol": "Lit",
"encryptedSymmetricKey": "ee71c216cc316c855ae83975f194ce3b8871d9012fe469adca17a99a09a421c5fe2a5b02867fd08cbdd6f6f053199a198223ea97233a2b422675bd7b93c4fb088449a708632433d5613c3b9798d0559884bf6c4d500bb7ad890aa95863e591a0589492825be3e32a850d41cb8ced76d3bf5039c438fdc3246884fe18cd19fbe40000000000000020c4eeed8e00c9d5661a4f9ffa827ee1b979f682af7edee6fbae8bb82f30f868a08b08c77637e40519985ba8ffbb535580",
"decryptionConditions": [
...
],
"decryptionConditionsType": "AccessControlCondition"
}
},
"createdAt": "2023-11-02T08:04:56.699Z",
"updatedAt": "2023-11-02T08:27:18.543Z"
}
}
}