Skip to content

Commit

Permalink
Merge pull request #147 from internxt/feat/PB-472-get-file-by-uuid
Browse files Browse the repository at this point in the history
[PB-472]: feat/get file by uuid
  • Loading branch information
rafijv authored Jun 16, 2023
2 parents dcdd056 + ccba6fd commit 62f030e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@internxt/sdk",
"version": "1.4.34",
"version": "1.4.35",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
10 changes: 10 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ThumbnailEntry,
Thumbnail,
FetchPaginatedFolderContentResponse,
FileMeta,
} from './types';
import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { HttpClient, RequestCanceler } from '../../shared/http/client';
Expand Down Expand Up @@ -100,6 +101,15 @@ export class Storage {
return [promise, requestCanceler];
}

/**
* Returns metadata of a specific file
* @param fileId
*/
public getFile(fileId: string): [Promise<FileMeta>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<FileMeta>(`/files/${fileId}/meta`, this.headers());
return [promise, requestCanceler];
}

/**
* Gets the files in a folder.
*
Expand Down
28 changes: 26 additions & 2 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,31 @@ export interface FetchFolderContentResponse {
user_id: number;
}

export interface FileMeta {
bucket: string;
createdAt: Date;
deleted: boolean;
deletedAt: Date | null;
encryptVersion: string;
fileId: string;
folder: string | null;
folderId: number;
folderUuid: string;
id: number;
modificationTime: string;
name: string;
plainName: string;
removed: boolean;
removedAt: Date | null;
size: string;
status: string;
type: string;
updatedAt: Date;
user: string | null;
userId: number;
uuid: string;
}

export interface FetchPaginatedFolderContentResponse {
result: {
bucket: string;
Expand Down Expand Up @@ -131,7 +156,6 @@ export interface FetchTrashContentResponse {
}[];
}


export enum EncryptionVersion {
Aes03 = '03-aes',
}
Expand Down Expand Up @@ -234,5 +258,5 @@ export interface FetchLimitResponse {
}

export interface AddItemsToTrashPayload {
items: Array<{id: string, type: string}>;
items: Array<{ id: string; type: string }>;
}

0 comments on commit 62f030e

Please sign in to comment.