Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ $ npm install -g @internxt/cli
$ internxt COMMAND
running command...
$ internxt (--version)
@internxt/cli/1.6.4 win32-x64 node-v24.3.0
@internxt/cli/1.6.5 win32-x64 node-v24.15.0
$ internxt --help [COMMAND]
USAGE
$ internxt COMMAND
Expand Down Expand Up @@ -139,7 +139,7 @@ EXAMPLES
$ internxt add-cert
```

_See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/add-cert.ts)_
_See code: [src/commands/add-cert.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/add-cert.ts)_

## `internxt add cert`

Expand Down Expand Up @@ -191,7 +191,7 @@ EXAMPLES
$ internxt autocomplete --refresh-cache
```

_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.41/src/commands/autocomplete/index.ts)_
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v3.2.50/src/commands/autocomplete/index.ts)_

## `internxt config`

Expand Down Expand Up @@ -220,7 +220,7 @@ EXAMPLES
$ internxt config
```

_See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/config.ts)_
_See code: [src/commands/config.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/config.ts)_

## `internxt create-folder`

Expand Down Expand Up @@ -254,7 +254,7 @@ EXAMPLES
$ internxt create-folder
```

_See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/create-folder.ts)_
_See code: [src/commands/create-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/create-folder.ts)_

## `internxt create folder`

Expand Down Expand Up @@ -318,7 +318,7 @@ EXAMPLES
$ internxt delete-permanently-file
```

_See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/delete-permanently-file.ts)_
_See code: [src/commands/delete-permanently-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/delete-permanently-file.ts)_

## `internxt delete-permanently-folder`

Expand Down Expand Up @@ -350,7 +350,7 @@ EXAMPLES
$ internxt delete-permanently-folder
```

_See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/delete-permanently-folder.ts)_
_See code: [src/commands/delete-permanently-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/delete-permanently-folder.ts)_

## `internxt delete permanently file`

Expand Down Expand Up @@ -445,7 +445,7 @@ EXAMPLES
$ internxt download-file
```

_See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/download-file.ts)_
_See code: [src/commands/download-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/download-file.ts)_

## `internxt download file`

Expand Down Expand Up @@ -508,7 +508,7 @@ EXAMPLES
$ internxt list
```

_See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/list.ts)_
_See code: [src/commands/list.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/list.ts)_

## `internxt login`

Expand Down Expand Up @@ -536,7 +536,7 @@ EXAMPLES
$ internxt login
```

_See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/login.ts)_
_See code: [src/commands/login.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/login.ts)_

## `internxt login-legacy`

Expand Down Expand Up @@ -570,7 +570,7 @@ EXAMPLES
$ internxt login-legacy
```

_See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/login-legacy.ts)_
_See code: [src/commands/login-legacy.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/login-legacy.ts)_

## `internxt logout`

Expand All @@ -590,7 +590,7 @@ EXAMPLES
$ internxt logout
```

_See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/logout.ts)_
_See code: [src/commands/logout.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/logout.ts)_

## `internxt logs`

Expand All @@ -610,7 +610,7 @@ EXAMPLES
$ internxt logs
```

_See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/logs.ts)_
_See code: [src/commands/logs.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/logs.ts)_

## `internxt move-file`

Expand Down Expand Up @@ -644,7 +644,7 @@ EXAMPLES
$ internxt move-file
```

_See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/move-file.ts)_
_See code: [src/commands/move-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/move-file.ts)_

## `internxt move-folder`

Expand Down Expand Up @@ -678,7 +678,7 @@ EXAMPLES
$ internxt move-folder
```

_See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/move-folder.ts)_
_See code: [src/commands/move-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/move-folder.ts)_

## `internxt move file`

Expand Down Expand Up @@ -775,7 +775,7 @@ EXAMPLES
$ internxt rename-file
```

_See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/rename-file.ts)_
_See code: [src/commands/rename-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/rename-file.ts)_

## `internxt rename-folder`

Expand Down Expand Up @@ -808,7 +808,7 @@ EXAMPLES
$ internxt rename-folder
```

_See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/rename-folder.ts)_
_See code: [src/commands/rename-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/rename-folder.ts)_

## `internxt rename file`

Expand Down Expand Up @@ -902,7 +902,7 @@ EXAMPLES
$ internxt trash-clear
```

_See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-clear.ts)_
_See code: [src/commands/trash-clear.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-clear.ts)_

## `internxt trash-file`

Expand Down Expand Up @@ -934,7 +934,7 @@ EXAMPLES
$ internxt trash-file
```

_See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-file.ts)_
_See code: [src/commands/trash-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-file.ts)_

## `internxt trash-folder`

Expand Down Expand Up @@ -966,7 +966,7 @@ EXAMPLES
$ internxt trash-folder
```

_See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-folder.ts)_
_See code: [src/commands/trash-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-folder.ts)_

## `internxt trash-list`

Expand All @@ -992,7 +992,7 @@ EXAMPLES
$ internxt trash-list
```

_See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-list.ts)_
_See code: [src/commands/trash-list.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-list.ts)_

## `internxt trash-restore-file`

Expand Down Expand Up @@ -1025,7 +1025,7 @@ EXAMPLES
$ internxt trash-restore-file
```

_See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-restore-file.ts)_
_See code: [src/commands/trash-restore-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-restore-file.ts)_

## `internxt trash-restore-folder`

Expand Down Expand Up @@ -1058,7 +1058,7 @@ EXAMPLES
$ internxt trash-restore-folder
```

_See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/trash-restore-folder.ts)_
_See code: [src/commands/trash-restore-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/trash-restore-folder.ts)_

## `internxt trash clear`

Expand Down Expand Up @@ -1267,7 +1267,7 @@ EXAMPLES
$ internxt upload-file
```

_See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/upload-file.ts)_
_See code: [src/commands/upload-file.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/upload-file.ts)_

## `internxt upload-folder`

Expand Down Expand Up @@ -1300,7 +1300,7 @@ EXAMPLES
$ internxt upload-folder
```

_See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/upload-folder.ts)_
_See code: [src/commands/upload-folder.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/upload-folder.ts)_

## `internxt upload file`

Expand Down Expand Up @@ -1388,7 +1388,7 @@ EXAMPLES
$ internxt webdav status
```

_See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/webdav.ts)_
_See code: [src/commands/webdav.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/webdav.ts)_

## `internxt webdav-config`

Expand Down Expand Up @@ -1427,7 +1427,7 @@ EXAMPLES
$ internxt webdav-config
```

_See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/webdav-config.ts)_
_See code: [src/commands/webdav-config.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/webdav-config.ts)_

## `internxt whoami`

Expand All @@ -1447,7 +1447,7 @@ EXAMPLES
$ internxt whoami
```

_See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/whoami.ts)_
_See code: [src/commands/whoami.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/whoami.ts)_

## `internxt workspaces-list`

Expand Down Expand Up @@ -1479,7 +1479,7 @@ EXAMPLES
$ internxt workspaces-list
```

_See code: [src/commands/workspaces-list.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/workspaces-list.ts)_
_See code: [src/commands/workspaces-list.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/workspaces-list.ts)_

## `internxt workspaces-unset`

Expand Down Expand Up @@ -1509,7 +1509,7 @@ EXAMPLES
$ internxt workspaces-unset
```

_See code: [src/commands/workspaces-unset.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/workspaces-unset.ts)_
_See code: [src/commands/workspaces-unset.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/workspaces-unset.ts)_

## `internxt workspaces-use`

Expand Down Expand Up @@ -1545,7 +1545,7 @@ EXAMPLES
$ internxt workspaces-use
```

_See code: [src/commands/workspaces-use.ts](https://github.com/internxt/cli/blob/v1.6.4/src/commands/workspaces-use.ts)_
_See code: [src/commands/workspaces-use.ts](https://github.com/internxt/cli/blob/v1.6.5/src/commands/workspaces-use.ts)_

## `internxt workspaces list`

Expand Down
47 changes: 16 additions & 31 deletions src/commands/upload-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import { DriveFileService } from '../services/drive/drive-file.service';
import { MissingCredentialsError, NotValidFileError } from '../types/command.types';
import { ValidationService } from '../services/validation.service';
import { EncryptionVersion } from '@internxt/sdk/dist/drive/storage/types';
import { BufferStream } from '../utils/stream.utils';
import { Readable } from 'node:stream';
import { ThumbnailUtils } from '../utils/thumbnail.utils';
import { ThumbnailService } from '../services/thumbnail.service';
import { AuthService } from '../services/auth.service';
import { UploadUtils } from '../utils/upload.utils';
import { BufferStream } from '../utils/stream.utils';

export default class UploadFile extends Command {
static readonly args = {};
Expand Down Expand Up @@ -82,19 +81,14 @@ export default class UploadFile extends Command {
progressBar?.start(100, 0);

let fileId: string | undefined;
let bufferStream: BufferStream | undefined;
const isThumbnailable = ThumbnailUtils.isFileThumbnailable(fileType);
let thumbnailStream: BufferStream | undefined;
const fileSize = stats.size ?? 0;

if (fileSize > 0) {
// Upload file to the Network
const readStream = createReadStream(filePath);
let fileStream: Readable = readStream;

if (isThumbnailable) {
bufferStream = new BufferStream();
fileStream = readStream.pipe(bufferStream);
}
const preparedStreams = UploadUtils.prepareUploadStreams(readStream, fileType);
thumbnailStream = preparedStreams.thumbnailStream;

const progressCallback = (progress: number) => {
progressBar?.update(progress * 100 * 0.99);
Expand All @@ -103,7 +97,7 @@ export default class UploadFile extends Command {
const abortable = new AbortController();

fileId = await networkFacade.uploadFile({
from: fileStream,
from: preparedStreams.fileStream,
size: fileSize,
bucketId: bucket,
progressCallback,
Expand Down Expand Up @@ -133,32 +127,23 @@ export default class UploadFile extends Command {
timings.driveUpload = driveUploadTimer.stop();

const thumbnailTimer = CLIUtils.timer();
if (fileSize > 0 && isThumbnailable && bufferStream) {
await ThumbnailService.instance.tryUploadThumbnail({
bufferStream,
fileType,
bucket,
fileUuid: createdDriveFile.uuid,
networkFacade,
size: fileSize,
});
}
await ThumbnailService.instance.tryUploadThumbnail({
bufferStream: thumbnailStream,
fileType,
bucket,
fileUuid: createdDriveFile.uuid,
networkFacade,
size: fileSize,
});
timings.thumbnailUpload = thumbnailTimer.stop();

progressBar?.update(100);
progressBar?.stop();

const totalTime = Object.values(timings).reduce((sum, time) => sum + time, 0);
const throughputMBps = CLIUtils.calculateThroughputMBps(stats.size, timings.networkUpload);
const { totalTime, timingBreakdown } = UploadUtils.getTimings(stats.size, timings);

if (flags['debug']) {
CLIUtils.log(
reporter,
'[PUT] Timing breakdown:\n' +
`Network upload: ${CLIUtils.formatDuration(timings.networkUpload)} (${throughputMBps.toFixed(2)} MB/s)\n` +
`Drive upload: ${CLIUtils.formatDuration(timings.driveUpload)}\n` +
`Thumbnail: ${CLIUtils.formatDuration(timings.thumbnailUpload)}\n`,
);
CLIUtils.log(reporter, timingBreakdown);
}
const workspace = await AuthService.instance.getCurrentWorkspace();
const workspaceId = workspace?.workspaceData.workspace.id;
Expand Down
Loading
Loading