Update File Expire Time
To update the file expire time with the bArchive API, utilize the updateFile
method from the SDK.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the updateFile
method:
import { Barchive, Network } from 'edeXa-sdk';
async function updateFileExpireTime() {
const barchive = new Barchive({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
const dataToUpdateFile = {
id: FILE_ID,
expireTimeInMinutes: EXPIRE_TIME, // Time should in minutes
}
try {
const addedFileResponse = await barchive.updateFile(dataToUpdateFile);
// Handle success
} catch (error) {
// Handle error
}
}
Key Points to Note
- Asynchronous Function: The
updateFile
function is an asynchronous (async
) function, employingawait
to wait for thebarchive.updateFile
promise to resolve. Once resolved successfully, the response for the file update is logged. In case of an error, it's reported usingconsole.error
. - Token and File ID Replacement: It's crucial to replace the
token
in theAuthorization
header with yourtoken
received from the authentication method andFILE_ID
with the actual file ID obtained via theaddFile
method. - Expiration Time Adjustment: Ensure to replace
EXPIRE_TIME
with the desired expiration time for the file.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
authorization | Yes | String | Enter your authentication token |
FILE_ID | Yes | Number | Enter the id of the file you want to read details from |
expireTimeInMinutes | Yes | Number | Enter the new expire time in minutes |
Response Format
Key | Type | Description |
---|---|---|
status | Number | Status code of the response |
message | String | Response message |