Skip to main content

Get File details

To get file details with the bArchive API, utilize the getFile method from the SDK.


Sample Code Snippet

Here is a JavaScript code snippet demonstrating the use of the getFile method:

import { Barchive, Network } from 'edeXa-sdk';

async function getStampDetail() {
const barchive = new Barchive({
...settings,
authorization: `Bearer ${token}`,
});
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
};

const fileId = {
id: 'FILE_ID'
}


try {
const fileDetails = await barchive.getFile(fileId);
// Handle success
} catch (error) {
// Handle error
}
}


Key Points to Note

  • Asynchronous Function: The getFile function is an asynchronous (async) function that uses await to wait for the barchive.getFile promise to resolve. Upon successful resolution, the file details are logged. If an error occurs, it is captured and recorded using console.error.
  • Token Replacement: It's essential to replace the token in the Authorization header with your own token, received as a response to the authentication method.
  • File ID Replacement: Ensure to replace FILE_ID with the actual id of the added file. The FILE_ID can be retrieved from the success response of the addFile method, as detailed in the Add File documentation.

Request Parameters

ParameterRequiredTypeDescription
authorizationYesStringEnter your authentication token
idYesNumberEnter the id of the file you want to read details from

Response Format

KeyTypeDescription
fileStringContent of the file
fileNameStringName of the file
fileSizeNumberSize of the file
mimeTypeStringMime type of the file