try {
const result = await hat.files().markFileAsPublic("file-id");
if (result.parsedBody) {
// result.parsedBody contains the File metadata.
}
} catch (error) {
// Failed to mark a file as public...
}
Mark a file as private
Parameters
Type
fileId
string
Response:
FileMetadataRes: The File metadata.
Example:
try {
const result = await hat.files().markFileAsPrivate("file-id");
if (result.parsedBody) {
// result.parsedBody contains the File metadata.
}
} catch (error) {
// Failed to mark a file as private...
}
Update File metadata
Parameters
Type
fileId
string
Response:
FileMetadataRes: The File metadata.
Example:
try {
const meta = {
"name": "differentFileName",
"source": "applicationName",
"tags": [
"iphone",
"photo",
"extra tag"
]
};
const result = await hat.files().updateFileParameters("file-id", meta);
if (result.parsedBody) {
// result.parsedBody contains the File metadata.
}
} catch (error) {
// Failed to update file's metadata...
}
Search Files
Parameters
Type
metadata
FileMetadataReq
Response:
Array: An array of File metadata.
Example:
try {
const meta = {
"name": "",
"source": "applicationName",
"tags": [
"iphone",
"photo",
]
};
const result = await hat.files().searchFiles(meta);
if (result.parsedBody) {
// result.parsedBody contains an array of File metadata.
// The result contains all the files with the tags "iphone" and "photo" with the same source.
}
} catch (error) {
// Failed to search for Files...
}
Delete File
Parameters
Type
fileId
string
Response:
FileMetadataRes: The File metadata.
Example:
try {
const result = await hat.files().deleteFile("file-id");
if (result.parsedBody) {
// result.parsedBody contains the File metadata.
}
} catch (error) {
// Failed to delete the File...
}
Generate File content URL
Parameters
Type
fileId
string
Response:
string: The URL to the content.
Example:
const url = hat.files().getFileContentUrl("file-id");
console.log(url);
// will print:
// https://<hat-url>/api/v2.6/files/content/<file-id>>
// The file will be available in this URL.
// Note: if the file is private, will need to pass the authentication token as
// a header to access the file.