Skip to main content

writefile

Description:

Add a new file or new version to existing file.

Request

https://api.moinet.io/moibit/v1/writefile

Request type - POST

Headers#

Header KeyHeader ValueOptional
nonce<developer_nonce> No
signature<signature gotten after signing developer_nonce by developer> No
developerKeypublic id of the developerNo
networkIDID of the network the file want to be written toNo
appIDID of the app the file want to be written to Yes
enduser_nonce<enduser nonce>No if enduser has moi_id
enduser_signature<signature gotten after signing enduser_nonce by enduser>No if enduser has moi_id
enduserIDId of the enduser if end-user doesn't have moi_id Yes

Content-Type: multipart/form-data

Parameters#

Param KeyParam TypeDescriptionOptional
fileNameStringFile name or path (default: filename in file header)Yes
fileBlobThe actual fileNo
keepPreviousBooleanEnsures that the previous version of the file was still maintained along with new file. Default:falseYes
createFoldersBooleanCreate folders as needed. Otherwise, if a path specified in fileName does not exist, the operation will fail. Default:true Yes
replicationIntegerNumber of file copies the network should maintain. Default: Min_RF of networkYes
encryptionTypeInteger-1 : No Encryption
0 : Default Network Encryption
1 : Developer Key Encryption
2 : Enduser Key Encryption
3 : Custom Key Encryption
4 : MES
Default: encryptionType of app or 0 if default-App
Yes

Write to Indus Testnet#

Just set isProvenance flag to true in your /writefile payload to write the same file/proof into MOI Indus testnet

isProvenanceBooleanSet this flag to true, if you want your file/proof also to be recorded in MOI Indus TestnetYes

Response Array#

FieldDescription
versionversion number of the file
hashContent identifier of the file
provenanceHashHash of the interaction in MOI Indus testnet
filesizeSize of the file uploaded
replication Number of copies created
encryptionType Encryption type of file
lastUpdatedDate with time when uploaded
directory Parent directory of the file being uploaded
path Absolute path of the file in system
recoveryTime Time duration till when one can recover this file once deleted
nodeAddressID of the node that processed this file

Sample Response#

{
"meta": {
"code": 200,
"requestId": "ac1efac5-5efe-45db-931b-166ca0751e70",
"message": "file(s) uploaded successfully"
},
"data": [
"[{\"active\":true,\"enable\":true,\"version\":1,\"hash\":\"Qmee4GNtKRpyQZgSJzCpSrweJbZgMVoD3roUkX886xjdo8\",\"filesize\":3028,\"replication\":3,\"filetype\":\"\",\"encryptionType\":0,\"encryptionKey\":\"163ea462e4428c3a5b45d20b95811113196e3fc5584f20ba56de175cf30a9f5d\",\"lastUpdated\":\"2021-05-25T14:03:16.620668162+02:00\",\"directory\":\"/\",\"isDir\":false,\"path\":\"/hello.pdf\",\"recoveryTime\":0,\"permanentDelete\":false,\"nodeAddress\":\"0xB8b9fE16E862042b76423B6a4fF5D1557B306adD\",\"appDeleted\":false,\"userDeleted\":false}]"
]
}