Skip to main content

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, employing await to wait for the barchive.updateFile promise to resolve. Once resolved successfully, the response for the file update is logged. In case of an error, it's reported using console.error.
  • Token and File ID Replacement: It's crucial to replace the token in the Authorization header with your token received from the authentication method and FILE_ID with the actual file ID obtained via the addFile method.
  • Expiration Time Adjustment: Ensure to replace EXPIRE_TIME with the desired expiration time for the file.

Request Parameters

ParameterRequiredTypeDescription
authorizationYesStringEnter your authentication token
FILE_IDYesNumberEnter the id of the file you want to read details from
expireTimeInMinutesYesNumberEnter the new expire time in minutes

Response Format

KeyTypeDescription
statusNumberStatus code of the response
messageStringResponse message