Delete File
To delete a file with the bArchive API, utilize the deleteFile
method from the SDK.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the deleteFile
method:
import { Barchive, Network } from 'edeXa-sdk';
async function removeFile() {
const barchive = new Barchive({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};
const dataToDeleteFile = {
id: FILE_ID,
}
try {
const deleteFileResponse = await barchive.deleteFile(dataToDeleteFile);
// Handle success
} catch (error) {
// Handle error
}
}
Key Points to Note
- Asynchronous Function: The
deleteFile
function is an asynchronous (async
) function, which usesawait
to pause execution until thebarchive.deleteFile
promise resolves. If the promise resolves successfully, the response for updating the file will be logged. In the event of an error, it will be caught and reported usingconsole.error
. - Token Replacement: Ensure to substitute
token
in theAuthorization
header with your actual token, obtained from the response of the authentication method. - File ID Replacement: Make sure to replace
FILE_ID
with the actual file ID you received after using theaddFile
method.
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
authorization | Yes | String | Enter your authentication token |
id | Yes | Number | Enter the id of the file you want to delete |
Response Format
Key | Type | Description |
---|---|---|
status | number | Status code of the response |
message | String | Response message |