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 usesawait
to wait for thebarchive.getFile
promise to resolve. Upon successful resolution, the file details are logged. If an error occurs, it is captured and recorded usingconsole.error
. - Token Replacement: It's essential to replace the
token
in theAuthorization
header with your owntoken
, received as a response to the authentication method. - File ID Replacement: Ensure to replace
FILE_ID
with the actualid
of the added file. TheFILE_ID
can be retrieved from the success response of theaddFile
method, as detailed in the Add File documentation.
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 read details from |
Response Format
Key | Type | Description |
---|---|---|
file | String | Content of the file |
fileName | String | Name of the file |
fileSize | Number | Size of the file |
mimeType | String | Mime type of the file |