try {constresult=awaithat.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 {constresult=awaithat.files().markFileAsPrivate("file-id");if (result.parsedBody) {// result.parsedBody contains the File metadata. }} catch (error) {// Failed to mark a file as private...}
try {constmeta= {"name":"","source":"applicationName","tags": ["iphone","photo", ] };constresult=awaithat.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 {constresult=awaithat.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:
consturl=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.