Skip to content

Commit d806c9d

Browse files
authored
Merge pull request #598 from internxt/feat/fix-put-handler
[_]: feat/fix-put-handler
2 parents d3b770b + f8e0ade commit d806c9d

29 files changed

Lines changed: 781 additions & 167 deletions

README.md

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ $ npm install -g @internxt/cli
5252
$ internxt COMMAND
5353
running command...
5454
$ internxt (--version)
55-
@internxt/cli/1.6.4 win32-x64 node-v24.3.0
55+
@internxt/cli/1.6.5 win32-x64 node-v24.15.0
5656
$ internxt --help [COMMAND]
5757
USAGE
5858
$ internxt COMMAND
@@ -139,7 +139,7 @@ EXAMPLES
139139
$ internxt add-cert
140140
```
141141

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

144144
## `internxt add cert`
145145

@@ -191,7 +191,7 @@ EXAMPLES
191191
$ internxt autocomplete --refresh-cache
192192
```
193193

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

196196
## `internxt config`
197197

@@ -220,7 +220,7 @@ EXAMPLES
220220
$ internxt config
221221
```
222222

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

225225
## `internxt create-folder`
226226

@@ -254,7 +254,7 @@ EXAMPLES
254254
$ internxt create-folder
255255
```
256256

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

259259
## `internxt create folder`
260260

@@ -318,7 +318,7 @@ EXAMPLES
318318
$ internxt delete-permanently-file
319319
```
320320

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

323323
## `internxt delete-permanently-folder`
324324

@@ -350,7 +350,7 @@ EXAMPLES
350350
$ internxt delete-permanently-folder
351351
```
352352

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

355355
## `internxt delete permanently file`
356356

@@ -445,7 +445,7 @@ EXAMPLES
445445
$ internxt download-file
446446
```
447447

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

450450
## `internxt download file`
451451

@@ -508,7 +508,7 @@ EXAMPLES
508508
$ internxt list
509509
```
510510

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

513513
## `internxt login`
514514

@@ -536,7 +536,7 @@ EXAMPLES
536536
$ internxt login
537537
```
538538

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

541541
## `internxt login-legacy`
542542

@@ -570,7 +570,7 @@ EXAMPLES
570570
$ internxt login-legacy
571571
```
572572

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

575575
## `internxt logout`
576576

@@ -590,7 +590,7 @@ EXAMPLES
590590
$ internxt logout
591591
```
592592

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

595595
## `internxt logs`
596596

@@ -610,7 +610,7 @@ EXAMPLES
610610
$ internxt logs
611611
```
612612

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

615615
## `internxt move-file`
616616

@@ -644,7 +644,7 @@ EXAMPLES
644644
$ internxt move-file
645645
```
646646

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

649649
## `internxt move-folder`
650650

@@ -678,7 +678,7 @@ EXAMPLES
678678
$ internxt move-folder
679679
```
680680

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

683683
## `internxt move file`
684684

@@ -775,7 +775,7 @@ EXAMPLES
775775
$ internxt rename-file
776776
```
777777

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

780780
## `internxt rename-folder`
781781

@@ -808,7 +808,7 @@ EXAMPLES
808808
$ internxt rename-folder
809809
```
810810

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

813813
## `internxt rename file`
814814

@@ -902,7 +902,7 @@ EXAMPLES
902902
$ internxt trash-clear
903903
```
904904

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

907907
## `internxt trash-file`
908908

@@ -934,7 +934,7 @@ EXAMPLES
934934
$ internxt trash-file
935935
```
936936

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

939939
## `internxt trash-folder`
940940

@@ -966,7 +966,7 @@ EXAMPLES
966966
$ internxt trash-folder
967967
```
968968

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

971971
## `internxt trash-list`
972972

@@ -992,7 +992,7 @@ EXAMPLES
992992
$ internxt trash-list
993993
```
994994

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

997997
## `internxt trash-restore-file`
998998

@@ -1025,7 +1025,7 @@ EXAMPLES
10251025
$ internxt trash-restore-file
10261026
```
10271027

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

10301030
## `internxt trash-restore-folder`
10311031

@@ -1058,7 +1058,7 @@ EXAMPLES
10581058
$ internxt trash-restore-folder
10591059
```
10601060

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

10631063
## `internxt trash clear`
10641064

@@ -1267,7 +1267,7 @@ EXAMPLES
12671267
$ internxt upload-file
12681268
```
12691269

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

12721272
## `internxt upload-folder`
12731273

@@ -1300,7 +1300,7 @@ EXAMPLES
13001300
$ internxt upload-folder
13011301
```
13021302

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

13051305
## `internxt upload file`
13061306

@@ -1388,7 +1388,7 @@ EXAMPLES
13881388
$ internxt webdav status
13891389
```
13901390

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

13931393
## `internxt webdav-config`
13941394

@@ -1427,7 +1427,7 @@ EXAMPLES
14271427
$ internxt webdav-config
14281428
```
14291429

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

14321432
## `internxt whoami`
14331433

@@ -1447,7 +1447,7 @@ EXAMPLES
14471447
$ internxt whoami
14481448
```
14491449

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

14521452
## `internxt workspaces-list`
14531453

@@ -1479,7 +1479,7 @@ EXAMPLES
14791479
$ internxt workspaces-list
14801480
```
14811481

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

14841484
## `internxt workspaces-unset`
14851485

@@ -1509,7 +1509,7 @@ EXAMPLES
15091509
$ internxt workspaces-unset
15101510
```
15111511

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

15141514
## `internxt workspaces-use`
15151515

@@ -1545,7 +1545,7 @@ EXAMPLES
15451545
$ internxt workspaces-use
15461546
```
15471547

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

15501550
## `internxt workspaces list`
15511551

WEBDAV.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ Find below the methods that are supported in the latest version of the Internxt
4646
| MKCOL ||
4747
| COPY ||
4848
| MOVE ||
49+
| LOCK ||
50+
| UNLOCK ||
4951

5052
## Requisites
5153

src/commands/upload-file.ts

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { DriveFileService } from '../services/drive/drive-file.service';
88
import { MissingCredentialsError, NotValidFileError } from '../types/command.types';
99
import { ValidationService } from '../services/validation.service';
1010
import { EncryptionVersion } from '@internxt/sdk/dist/drive/storage/types';
11-
import { BufferStream } from '../utils/stream.utils';
12-
import { Readable } from 'node:stream';
13-
import { ThumbnailUtils } from '../utils/thumbnail.utils';
1411
import { ThumbnailService } from '../services/thumbnail.service';
1512
import { AuthService } from '../services/auth.service';
13+
import { UploadUtils } from '../utils/upload.utils';
14+
import { BufferStream } from '../utils/stream.utils';
1615

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

8483
let fileId: string | undefined;
85-
let bufferStream: BufferStream | undefined;
86-
const isThumbnailable = ThumbnailUtils.isFileThumbnailable(fileType);
84+
let thumbnailStream: BufferStream | undefined;
8785
const fileSize = stats.size ?? 0;
8886

8987
if (fileSize > 0) {
9088
// Upload file to the Network
9189
const readStream = createReadStream(filePath);
92-
let fileStream: Readable = readStream;
93-
94-
if (isThumbnailable) {
95-
bufferStream = new BufferStream();
96-
fileStream = readStream.pipe(bufferStream);
97-
}
90+
const preparedStreams = UploadUtils.prepareUploadStreams(readStream, fileType);
91+
thumbnailStream = preparedStreams.thumbnailStream;
9892

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

10599
fileId = await networkFacade.uploadFile({
106-
from: fileStream,
100+
from: preparedStreams.fileStream,
107101
size: fileSize,
108102
bucketId: bucket,
109103
progressCallback,
@@ -133,32 +127,23 @@ export default class UploadFile extends Command {
133127
timings.driveUpload = driveUploadTimer.stop();
134128

135129
const thumbnailTimer = CLIUtils.timer();
136-
if (fileSize > 0 && isThumbnailable && bufferStream) {
137-
await ThumbnailService.instance.tryUploadThumbnail({
138-
bufferStream,
139-
fileType,
140-
bucket,
141-
fileUuid: createdDriveFile.uuid,
142-
networkFacade,
143-
size: fileSize,
144-
});
145-
}
130+
await ThumbnailService.instance.tryUploadThumbnail({
131+
bufferStream: thumbnailStream,
132+
fileType,
133+
bucket,
134+
fileUuid: createdDriveFile.uuid,
135+
networkFacade,
136+
size: fileSize,
137+
});
146138
timings.thumbnailUpload = thumbnailTimer.stop();
147139

148140
progressBar?.update(100);
149141
progressBar?.stop();
150142

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

154145
if (flags['debug']) {
155-
CLIUtils.log(
156-
reporter,
157-
'[PUT] Timing breakdown:\n' +
158-
`Network upload: ${CLIUtils.formatDuration(timings.networkUpload)} (${throughputMBps.toFixed(2)} MB/s)\n` +
159-
`Drive upload: ${CLIUtils.formatDuration(timings.driveUpload)}\n` +
160-
`Thumbnail: ${CLIUtils.formatDuration(timings.thumbnailUpload)}\n`,
161-
);
146+
CLIUtils.log(reporter, timingBreakdown);
162147
}
163148
const workspace = await AuthService.instance.getCurrentWorkspace();
164149
const workspaceId = workspace?.workspaceData.workspace.id;

0 commit comments

Comments
 (0)