-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUploadView.vue
More file actions
1659 lines (1499 loc) · 58.3 KB
/
UploadView.vue
File metadata and controls
1659 lines (1499 loc) · 58.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<template>
<div class="max-w-5xl mx-auto px-2 sm:px-4">
<!-- Hero Section -->
<div class="text-center mb-8 sm:mb-12 max-w-4xl mx-auto -mt-4">
<!-- Designer Cat Animation -->
<div class="flex justify-center mb-4">
<Vue3Lottie
:animationData="DesignerCatAnimation"
:height="200"
:width="200"
class="sm:!h-[250px] sm:!w-[250px] md:!h-[280px] md:!w-[280px]"
:loop="true"
/>
</div>
<div class="flex flex-col md:flex-row items-center justify-center gap-4 sm:gap-6 mb-4 px-2">
<img src="/logo.png" alt="FileDuck Logo" class="h-24 sm:h-32 md:h-40 w-24 sm:w-32 md:w-40 object-contain" />
<h1 class="text-4xl sm:text-5xl md:text-6xl lg:text-7xl font-extrabold font-display tracking-tight text-indigo-950 leading-tight text-center md:text-left">
Share Files Securely
</h1>
</div>
<!-- Scanning Animation Component -->
<div class="-mt-4 mb-3">
<ScanningAnimation />
</div>
<p class="text-xl text-gray-600 mb-3 max-w-2xl mx-auto leading-relaxed">
Upload, scan, and share files with enterprise-grade security. Protected by AI-powered malware detection and end-to-end encryption.
</p>
<div class="bg-gradient-to-r from-green-50 to-blue-50 border-2 border-green-200 rounded-xl p-4 mb-6 max-w-2xl mx-auto">
<p class="text-sm text-gray-700 flex items-center justify-center">
<LockIcon class="w-5 h-5 mr-2 text-green-600" />
<strong class="text-green-700 mr-1">End-to-End Encrypted:</strong>
Your data is encrypted during transfer. Only sender and receiver can access the content.
</p>
</div>
<div class="flex flex-wrap justify-center gap-4 mb-8">
<div class="flex items-center space-x-2 bg-white px-4 py-2 rounded-xl shadow-sm border border-purple-100 hover:shadow-md transition-shadow">
<img src="/malware scanned.png" alt="Malware Protected" class="h-10 object-contain" />
</div>
<div class="flex items-center space-x-2 bg-white px-4 py-2 rounded-xl shadow-sm border border-purple-100 hover:shadow-md transition-shadow">
<img src="/cdn.png" alt="Global CDN" class="h-10 object-contain" />
</div>
<div class="flex items-center space-x-2 bg-white px-4 py-2 rounded-xl shadow-sm border border-purple-100 hover:shadow-md transition-shadow">
<img src="/privacy.png" alt="Privacy Protected" class="h-10 object-contain" />
</div>
</div>
<!-- Product Hunt Badge -->
<div class="flex justify-center mb-8">
<a
href="https://www.producthunt.com/products/fileduck?launch=fileduck"
target="_blank"
rel="noopener noreferrer"
class="inline-block transform hover:scale-105 transition-all duration-300 shadow-lg hover:shadow-xl"
>
<img src="/product hint.png" alt="#1 Product of the Day on Product Hunt" class="h-16 md:h-20 object-contain" />
</a>
</div>
</div>
<!-- Live Activity Tracker -->
<div class="max-w-4xl mx-auto mb-12">
<LiveActivityTracker />
</div>
<!-- Main Upload Card -->
<div id="upload" class="bg-white rounded-2xl sm:rounded-3xl shadow-xl p-4 sm:p-6 md:p-10 border border-purple-100 max-w-3xl mx-auto mb-12 sm:mb-20 scroll-mt-20">
<div v-if="!uploadComplete" class="space-y-6">
<!-- File Selection with Animation -->
<div
@click="triggerFileInput"
@drop.prevent="handleDrop"
@dragover.prevent
@dragenter="isDragging = true"
@dragleave="isDragging = false"
:class="[
'border-2 sm:border-3 border-dashed rounded-xl sm:rounded-2xl p-6 sm:p-8 md:p-12 text-center cursor-pointer transition-all duration-300',
isDragging
? 'border-purple-400 bg-purple-50'
: 'border-purple-200 hover:border-purple-300 hover:bg-purple-50/30',
]"
>
<input
type="file"
ref="fileInput"
@change="handleFileSelect"
class="hidden"
id="file-input"
accept="*/*"
/>
<div class="cursor-pointer">
<div v-if="!selectedFile" class="flex flex-col items-center">
<Vue3Lottie
:animationData="UploadFilesAnimation"
:height="120"
:width="120"
class="sm:!h-[140px] sm:!w-[140px] md:!h-[160px] md:!w-[160px]"
:loop="true"
/>
<p class="text-xl sm:text-2xl font-bold text-gray-800 mt-4 sm:mt-6 px-2">
Drop your file here
</p>
<p class="text-sm sm:text-base text-gray-500 mt-2">or click to browse</p>
<p class="text-xs sm:text-sm text-gray-400 mt-3 sm:mt-4 flex items-center justify-center">
<HardDriveIcon class="w-4 h-4 mr-2" />
Maximum file size: 500GB • Pause/Resume supported
</p>
</div>
<div v-else class="relative flex items-center justify-between bg-purple-50 rounded-xl p-6 border border-purple-200">
<div class="flex items-center space-x-4">
<FileIcon class="w-12 h-12 text-purple-400" />
<div class="text-left">
<p class="text-xl font-bold text-gray-800">{{ selectedFile.name }}</p>
<p class="text-base text-gray-600 flex items-center mt-1">
<HardDriveIcon class="w-4 h-4 mr-1" />
{{ formatSize(selectedFile.size) }}
</p>
</div>
</div>
<button
@click.stop="removeFile"
class="absolute top-4 right-4 p-2 rounded-full bg-red-500 hover:bg-red-600 text-white transition-all hover:scale-110"
title="Remove file"
>
<XIcon class="w-5 h-5" />
</button>
</div>
</div>
</div>
<!-- Scanning in Progress -->
<div v-if="isScanning" class="bg-blue-50 border-2 border-blue-200 rounded-xl p-6">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<Vue3Lottie
:animationData="ScanningDocumentAnimation"
:height="80"
:width="80"
:loop="true"
/>
</div>
<div class="flex-1">
<p class="text-lg font-bold text-blue-800 mb-1">🔍 Scanning for malware...</p>
<p class="text-sm text-blue-600">Please wait while we verify your file is safe.</p>
</div>
</div>
</div>
<!-- File Clean Message (Only after scan is clean) -->
<div v-else-if="scanStatus === 'clean' && !uploadComplete" class="bg-green-50 border-2 border-green-200 rounded-xl p-6">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<ShieldCheckIcon class="w-12 h-12 text-green-600" />
</div>
<div class="flex-1">
<p class="text-lg font-bold text-green-800">✓ File is virus free</p>
<p class="text-sm text-green-600">No viruses found. Uploading...</p>
</div>
</div>
</div>
<!-- Malicious File Warning (Only after scan detects threat) -->
<div v-else-if="scanStatus === 'malicious' && !virusDetails.includes('Scan error')" class="bg-red-50 border-2 border-red-300 rounded-xl p-6">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<Vue3Lottie
:animationData="COVID19Animation"
:height="100"
:width="100"
:loop="true"
/>
</div>
<div class="flex-1">
<div class="flex items-center space-x-2 mb-2">
<AlertTriangleIcon class="w-7 h-7 text-red-600" />
<p class="text-xl font-bold text-red-800">⚠️ Malicious File Detected!</p>
</div>
<p class="text-red-700 font-medium mb-2">
{{ virusDetails || 'This file contains potentially harmful content and cannot be uploaded.' }}
</p>
<p class="text-sm text-red-600">
Please select a different file to upload.
</p>
</div>
</div>
</div>
<!-- Scan Error Warning (When scanning fails) -->
<div v-else-if="scanStatus === 'malicious' && virusDetails.includes('Scan error')" class="bg-orange-50 border-2 border-orange-300 rounded-xl p-6">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<Vue3Lottie
:animationData="StressedWomanAnimation"
:height="100"
:width="100"
:loop="true"
/>
</div>
<div class="flex-1">
<div class="flex items-center space-x-2 mb-2">
<AlertTriangleIcon class="w-7 h-7 text-orange-600" />
<p class="text-xl font-bold text-orange-800">😰 Scanning Error</p>
</div>
<p class="text-orange-700 font-medium mb-2">
{{ virusDetails }}
</p>
<p class="text-sm text-orange-600">
Please try again or contact support if the issue persists.
</p>
</div>
</div>
</div>
<!-- Scan Skipped Warning (Large files or scanner unavailable) -->
<div v-else-if="scanStatus === 'skipped'" class="bg-yellow-50 border-2 border-yellow-300 rounded-xl p-6">
<div class="flex items-center space-x-4">
<div class="flex-shrink-0">
<AlertTriangleIcon class="w-16 h-16 text-yellow-600" />
</div>
<div class="flex-1">
<div class="flex items-center space-x-2 mb-2">
<AlertTriangleIcon class="w-7 h-7 text-yellow-600" />
<p class="text-xl font-bold text-yellow-800">
⚠️
<span v-if="scanSkipReason === 'too_large'">File Too Large for Scanning</span>
<span v-else-if="scanSkipReason === 'scanner_unavailable'">Scanner Temporarily Unavailable</span>
<span v-else-if="selectedFile && selectedFile.size > 50 * 1024 * 1024">Large File - Scanning Disabled by Default</span>
<span v-else>Scanning Disabled</span>
</p>
</div>
<p class="text-yellow-700 font-medium mb-2">
<span v-if="scanSkipReason === 'too_large'">
This file is larger than 100MB and cannot be scanned with our malware scanner.
</span>
<span v-else-if="scanSkipReason === 'scanner_unavailable'">
Our large-file scanner is currently unavailable.
</span>
<span v-else-if="selectedFile && selectedFile.size > 50 * 1024 * 1024">
Large files (>50MB) have scanning disabled by default to reduce delays.
</span>
<span v-else>
You have disabled malware scanning for this file.
</span>
</p>
<p class="text-sm text-yellow-600 mb-3">
The file will be uploaded <strong>without malware scanning</strong>. Recipients will be warned that this file was not scanned.
</p>
<p class="text-xs text-yellow-600" v-if="selectedFile && selectedFile.size > 50 * 1024 * 1024">
💡 <strong>Tip:</strong> Enable scanning toggle above to scan files before upload. Large files may take longer to scan.
</p>
<p class="text-xs text-yellow-600" v-else>
💡 <strong>Tip:</strong> Enable the scanning toggle above to scan this file for malware before upload.
</p>
</div>
</div>
</div>
<!-- SHA256 Hash for Verification -->
<div v-if="selectedFile && sha256Hash" class="bg-gradient-to-r from-blue-50 to-indigo-50 border-2 border-blue-200 rounded-xl p-5">
<p class="text-sm font-semibold text-gray-700 mb-2 flex items-center">
<ShieldCheckIcon class="w-4 h-4 mr-2 text-blue-600" />
File Verification Hash (SHA-256)
</p>
<p class="text-xs text-gray-600 mb-3">
This unique code verifies your file hasn't been tampered with during transfer
</p>
<div class="flex items-center justify-between bg-white rounded-lg p-3 border border-blue-100">
<p class="font-mono text-xs text-blue-600 break-all flex-1">
{{ sha256Hash }}
</p>
<button @click="copyHash" class="ml-3 text-blue-500 hover:text-blue-600 hover:scale-110 transition-transform flex-shrink-0">
<CopyIcon class="w-5 h-5" />
</button>
</div>
</div>
<!-- Upload Options -->
<div v-if="selectedFile" class="space-y-5 bg-white rounded-xl p-6 border border-purple-100">
<div>
<label class="flex items-center text-base font-semibold text-gray-700 mb-3">
<ClockIcon class="w-5 h-5 mr-2 text-purple-400" />
Time to Live
</label>
<select v-model="ttlHours" class="input-field text-base w-full p-3 border border-gray-200 rounded-lg focus:border-purple-300 focus:ring-2 focus:ring-purple-100 bg-white font-sans font-medium text-gray-800 cursor-pointer hover:border-purple-400 transition-colors">
<option :value="1" class="font-sans font-medium text-gray-800 py-2">1 hour</option>
<option :value="6" class="font-sans font-medium text-gray-800 py-2">6 hours</option>
<option :value="24" class="font-sans font-medium text-gray-800 py-2">24 hours (default)</option>
<option :value="72" class="font-sans font-medium text-gray-800 py-2">3 days</option>
<option :value="168" class="font-sans font-medium text-gray-800 py-2">7 days</option>
</select>
</div>
<div>
<label class="flex items-center text-base font-semibold text-gray-700 mb-3">
<DownloadIcon class="w-5 h-5 mr-2 text-lemon-500" />
Maximum Downloads
</label>
<select v-model="maxUses" class="input-field text-base w-full p-3 border border-gray-200 rounded-lg focus:border-purple-300 focus:ring-2 focus:ring-purple-100 bg-white font-sans font-medium text-gray-800 cursor-pointer hover:border-purple-400 transition-colors">
<option :value="1" class="font-sans font-medium text-gray-800 py-2">One-time (default)</option>
<option :value="3" class="font-sans font-medium text-gray-800 py-2">3 downloads</option>
<option :value="5" class="font-sans font-medium text-gray-800 py-2">5 downloads</option>
<option :value="10" class="font-sans font-medium text-gray-800 py-2">10 downloads</option>
<option :value="999" class="font-sans font-medium text-gray-800 py-2">Unlimited</option>
</select>
</div>
<div class="flex items-center space-x-3 bg-purple-50 rounded-lg p-4 border border-purple-100">
<label class="neon-checkbox">
<input type="checkbox" v-model="enableEncryption" id="encryption" />
<div class="neon-checkbox__frame">
<div class="neon-checkbox__box">
<div class="neon-checkbox__check-container">
<svg viewBox="0 0 24 24" class="neon-checkbox__check">
<path d="M3,12.5l7,7L21,5"></path>
</svg>
</div>
<div class="neon-checkbox__glow"></div>
<div class="neon-checkbox__borders">
<span></span><span></span><span></span><span></span>
</div>
</div>
<div class="neon-checkbox__effects">
<div class="neon-checkbox__particles">
<span></span><span></span><span></span><span></span>
<span></span><span></span><span></span><span></span>
<span></span><span></span><span></span><span></span>
</div>
<div class="neon-checkbox__rings">
<div class="ring"></div>
<div class="ring"></div>
<div class="ring"></div>
</div>
<div class="neon-checkbox__sparks">
<span></span><span></span><span></span><span></span>
</div>
</div>
</div>
</label>
<label for="encryption" class="flex items-center text-base font-medium text-gray-700 cursor-pointer">
<LockIcon class="w-5 h-5 mr-2 text-purple-400" />
Enable client-side encryption (zero-knowledge)
</label>
</div>
<!-- Captcha Toggle -->
<CaptchaToggle v-model="requireCaptcha" :isAutoEnabled="isCaptchaAutoEnabled" />
<!-- Scan Toggle -->
<ScanToggle v-model="enableScan" />
</div>
<!-- Upload Progress with Animation -->
<div v-if="isUploading || isPaused" class="space-y-5 bg-white rounded-xl p-8 border border-purple-100">
<div class="flex justify-center">
<Vue3Lottie
ref="uploadLottieRef"
:animationData="FileStorageAnimation"
:height="140"
:width="140"
:loop="true"
:autoplay="!isPaused"
:paused="isPaused"
/>
</div>
<div class="space-y-3">
<div class="flex justify-between text-base font-semibold text-gray-700">
<span class="flex items-center">
<UploadIcon class="w-5 h-5 mr-2 text-purple-400" />
{{ isPaused ? 'Upload Paused' : 'Uploading...' }}
</span>
<span class="font-bold text-xl text-purple-500">{{ uploadProgress }}%</span>
</div>
<div class="w-full h-5 rail-track relative p-[2px]">
<div
class="h-full plasma-fill rounded-sm"
:class="{ 'progress-bar-animated': !isPaused, 'progress-bar-paused': isPaused }"
:style="{ width: uploadProgress + '%' }"
>
<div v-if="uploadProgress > 0 && !isPaused" class="fusion-head"></div>
</div>
</div>
<!-- Upload Stats -->
<div class="flex justify-between text-sm text-gray-600">
<span>{{ uploadSpeed }}</span>
<span>{{ timeRemaining }}</span>
</div>
<!-- Pause/Resume Button -->
<div class="flex flex-col items-center gap-2 mt-4">
<div class="flex gap-3">
<button
v-if="!isPaused"
@click="pauseUpload"
class="px-6 py-2 bg-yellow-500 hover:bg-yellow-600 text-white rounded-lg font-semibold transition-colors flex items-center space-x-2"
>
<PauseIcon class="w-5 h-5" />
<span>Pause</span>
</button>
<button
v-else
@click="resumeUpload"
class="px-6 py-2 bg-green-500 hover:bg-green-600 text-white rounded-lg font-semibold transition-colors flex items-center space-x-2"
>
<PlayIcon class="w-5 h-5" />
<span>Resume</span>
</button>
</div>
<p v-if="isPaused" class="text-xs text-gray-500 text-center">
✓ Progress saved - Resume will continue from where you left off
</p>
</div>
</div>
</div>
<!-- Upload Button -->
<button
@click="uploadFile"
:disabled="!selectedFile || isUploading || isScanning || scanStatus === 'malicious'"
class="btn-primary w-full text-lg py-4 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center transition-all"
>
<RocketIcon v-if="!isUploading && !isScanning" class="w-6 h-6 mr-2" />
<LoaderIcon v-else class="w-6 h-6 mr-2 animate-spin" />
{{ isScanning ? 'Scanning...' : (isUploading ? 'Uploading...' : (scanStatus === 'clean' ? 'Upload File' : (scanStatus === 'skipped' ? 'Upload File (Unscanned)' : 'Scan & Upload File'))) }}
</button>
</div>
<!-- Success View -->
<div v-else class="space-y-6">
<div class="text-center py-8">
<Vue3Lottie
:animationData="UploadSuccessAnimation"
:height="180"
:width="180"
:loop="true"
/>
<h2 class="text-3xl font-bold text-gray-800 mb-2 mt-4">
File Uploaded Successfully!
</h2>
<p class="text-gray-500">Share your code to let others download</p>
</div>
<div class="bg-purple-50 border-2 border-purple-200 rounded-xl p-8">
<p class="text-base font-semibold text-gray-700 mb-3 flex items-center">
<KeyIcon class="w-5 h-5 mr-2 text-purple-400" />
Share Code
</p>
<div class="flex items-center justify-between bg-white rounded-lg p-5 border border-purple-100">
<p class="font-mono text-3xl font-bold text-purple-500">
{{ shareCode }}
</p>
<button @click="copyShareCode" class="text-purple-400 hover:text-purple-500 hover:scale-110 transition-transform">
<CopyIcon class="w-8 h-8" />
</button>
</div>
</div>
<div class="bg-lemon-50 border-2 border-lemon-200 rounded-xl p-6 space-y-3 text-base">
<p class="flex items-center">
<FileIcon class="w-5 h-5 mr-3 text-gray-600" />
<strong class="text-gray-800">Filename:</strong> <span class="text-gray-600">{{ selectedFile?.name }}</span>
</p>
<p class="flex items-center">
<HardDriveIcon class="w-5 h-5 mr-3 text-gray-600" />
<strong class="text-gray-800">Size:</strong> <span class="text-gray-600">{{ formatSize(selectedFile?.size || 0) }}</span>
</p>
<p class="flex items-center">
<ClockIcon class="w-5 h-5 mr-3 text-gray-600" />
<strong class="text-gray-800">Expires:</strong> <span class="text-gray-600">{{ formatExpiry(expiresAt) }}</span>
</p>
<p class="flex items-center">
<DownloadIcon class="w-5 h-5 mr-3 text-gray-600" />
<strong class="text-gray-800">Downloads left:</strong> <span class="text-gray-600">{{ maxUses === 999 ? 'Unlimited' : maxUses }}</span>
</p>
</div>
<!-- SHA256 Hash Verification -->
<div class="bg-gradient-to-r from-blue-50 to-indigo-50 border-2 border-blue-200 rounded-xl p-5">
<p class="text-sm font-semibold text-gray-700 mb-2 flex items-center">
<ShieldCheckIcon class="w-4 h-4 mr-2 text-blue-600" />
File Verification Hash (SHA-256)
</p>
<p class="text-xs text-gray-600 mb-3">
Share this hash with recipients to verify file integrity. They can compare it after download to ensure the file hasn't been modified.
</p>
<div class="flex items-center justify-between bg-white rounded-lg p-3 border border-blue-100">
<p class="font-mono text-xs text-blue-600 break-all flex-1">
{{ sha256Hash }}
</p>
<button @click="copyHash" class="ml-3 text-blue-500 hover:text-blue-600 hover:scale-110 transition-transform flex-shrink-0">
<CopyIcon class="w-5 h-5" />
</button>
</div>
</div>
<!-- Scanning Status -->
<div v-if="isScanning" class="bg-white border-2 border-purple-200 rounded-xl p-6">
<div class="flex items-center">
<Vue3Lottie
:animationData="ScanningDocumentAnimation"
:height="60"
:width="60"
:loop="true"
class="mr-4"
/>
<p class="text-base text-gray-700">
<strong class="text-lg text-gray-800">Scanning for viruses and malware...</strong><br/>
<span class="text-gray-500">Please wait while we verify your file is safe.</span>
</p>
</div>
</div>
<!-- Malware Detected Warning -->
<div v-else-if="scanStatus === 'malicious'" class="bg-red-50 border-3 border-red-300 rounded-xl p-6">
<div class="flex items-start">
<Vue3Lottie
:animationData="ShockedDuckAnimation"
:height="80"
:width="80"
:loop="false"
class="mr-4 flex-shrink-0"
/>
<div class="flex-1">
<p class="text-lg font-bold text-red-900 mb-3 flex items-center">
<AlertTriangleIcon class="w-6 h-6 mr-2" />
MALICIOUS FILE DETECTED!
</p>
<p class="text-base text-red-800 mb-4 bg-white/50 p-3 rounded">
{{ virusDetails }}
</p>
<p class="text-sm text-red-700 mb-4">
<strong>File has been quarantined.</strong> This file will not be available for public download. Only users you explicitly share the code with will be warned before download.
</p>
<div class="flex items-center space-x-3 bg-white/70 rounded-lg p-3">
<input
type="checkbox"
v-model="allowQuarantine"
id="acknowledge-risk"
class="w-5 h-5 text-red-600"
/>
<label for="acknowledge-risk" class="text-sm text-red-900 font-semibold">
I understand the risks and want to keep this file in quarantine for controlled sharing
</label>
</div>
</div>
</div>
</div>
<!-- Clean Scan Result -->
<div v-else-if="scanStatus === 'clean'" class="bg-green-50 border-2 border-green-200 rounded-xl p-5">
<p class="text-base text-gray-700 flex items-center">
<ShieldCheckIcon class="w-6 h-6 mr-3 text-green-600" />
<strong class="text-base text-gray-800">Scan complete:</strong> <span class="text-green-600">No threats detected. File is safe to share.</span>
</p>
</div>
<button @click="resetForm" class="btn-secondary w-full flex items-center justify-center text-lg py-4">
<RefreshCwIcon class="w-6 h-6 mr-2" />
Upload Another File
</button>
</div>
</div>
<!-- How It Works Section -->
<HowItWorks />
<!-- Testimonials Section -->
<Testimonials />
<!-- About Section -->
<AboutSection />
<!-- Trusted By Section -->
<TrustedBy />
<!-- CTA Section -->
<CTASection />
<!-- Info Boxes -->
<div class="grid md:grid-cols-3 gap-6 mt-16 mb-12 max-w-6xl mx-auto">
<!-- Malware Scanned Badge -->
<div class="bg-white rounded-2xl p-6 shadow-lg hover:shadow-xl transition-all border border-purple-100 aspect-square flex flex-col">
<div class="flex-1 flex flex-col items-center justify-center text-center">
<div class="mb-4 w-full flex justify-center">
<img src="/malware scanned.png" alt="AI-Powered Malware Scanning" class="w-32 h-32 object-contain" />
</div>
<h3 class="font-bold text-lg text-gray-900 mb-2">AI-Powered Protection</h3>
<p class="text-sm text-gray-600 leading-relaxed">
Every file is scanned using advanced threat detection for complete safety.
</p>
</div>
</div>
<!-- Global CDN Badge -->
<div class="bg-white rounded-2xl p-6 shadow-lg hover:shadow-xl transition-all border border-yellow-100 aspect-square flex flex-col">
<div class="flex-1 flex flex-col items-center justify-center text-center">
<div class="mb-4 w-full flex justify-center">
<img src="/cdn.png" alt="Global CDN Network" class="w-32 h-32 object-contain" />
</div>
<h3 class="font-bold text-lg text-gray-900 mb-2">Lightning-Fast Delivery</h3>
<p class="text-sm text-gray-600 leading-relaxed">
Powered by global CDN with servers worldwide for blazing-fast downloads.
</p>
</div>
</div>
<!-- Privacy Badge -->
<div class="bg-white rounded-2xl p-6 shadow-lg hover:shadow-xl transition-all border border-purple-100 aspect-square flex flex-col">
<div class="flex-1 flex flex-col items-center justify-center text-center">
<div class="mb-4 w-full flex justify-center">
<img src="/privacy.png" alt="Privacy-First Architecture" class="w-32 h-32 object-contain" />
</div>
<h3 class="font-bold text-lg text-gray-900 mb-2">Privacy-First Design</h3>
<p class="text-sm text-gray-600 leading-relaxed">
Zero-knowledge encryption and time-limited links keep your files completely private.
</p>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, watch } from 'vue';
import { Vue3Lottie } from 'vue3-lottie';
import HowItWorks from '../components/HowItWorks.vue';
import Testimonials from '../components/Testimonials.vue';
import AboutSection from '../components/AboutSection.vue';
import LiveActivityTracker from '../components/LiveActivityTracker.vue';
import ScanningAnimation from '../components/ScanningAnimation.vue';
import CaptchaToggle from '../components/CaptchaToggle.vue';
import ScanToggle from '../components/ScanToggle.vue';
import { useNotifications } from '../composables/useNotifications';
import TrustedBy from '../components/TrustedBy.vue';
import CTASection from '../components/CTASection.vue';
import {
FileIcon, ShieldCheckIcon, CopyIcon, ClockIcon, DownloadIcon,
LockIcon, UploadIcon, RocketIcon, LoaderIcon, KeyIcon,
HardDriveIcon, RefreshCwIcon, GlobeIcon, EyeOffIcon, AlertTriangleIcon, ZapIcon, XIcon,
PauseIcon, PlayIcon
} from 'lucide-vue-next';
import { computeSHA256, formatFileSize, formatTimeRemaining } from '@fileduck/shared';
import { uploadFileMeta, uploadToS3, scanFileBeforeUpload } from '../services/api';
import { addToUploadHistory, requestPersistentStorage } from '../services/uploadHistory';
import {
saveResumableUploadState,
getResumableUploadState,
deleteResumableUploadState,
markChunkUploaded,
isChunkUploaded,
setUploadPaused,
type ResumableUploadState
} from '../services/resumableUpload';
const { success, error } = useNotifications();
// Import animations
import FileStorageAnimation from '../../../../animations/File storage.json';
import UploadFilesAnimation from '../../../../animations/Upload Files.json';
import UploadSuccessAnimation from '../../../../animations/upload success.json';
import ScanningDocumentAnimation from '../../../../animations/Scanning document.json';
import COVID19Animation from '../../../../animations/COVID19.json';
import DesignerCatAnimation from '../../../../animations/Designer cat.json';
import StressedWomanAnimation from '../../../../animations/Stressed Woman at work.json';
const fileInput = ref<HTMLInputElement | null>(null);
const uploadLottieRef = ref<any>(null);
const selectedFile = ref<File | null>(null);
const sha256Hash = ref('');
const verificationCode = ref('');
const isDragging = ref(false);
const isUploading = ref(false);
const uploadProgress = ref(0);
const uploadComplete = ref(false);
const shareCode = ref('');
const expiresAt = ref(0);
const ttlHours = ref(24);
const maxUses = ref(1);
const enableEncryption = ref(false);
const isScanning = ref(false);
const scanStatus = ref<'pending' | 'clean' | 'malicious' | 'skipped' | null>(null);
const virusDetails = ref('');
const scanSkipReason = ref<'too_large' | 'user_disabled' | 'scanner_unavailable' | ''>('');
const allowQuarantine = ref(false);
const requireCaptcha = ref(false);
const enableScan = ref(true); // Scanning ON by default for small files
const isCaptchaAutoEnabled = ref(false); // Track if captcha was auto-enabled
// Pause/Resume state
const isPaused = ref(false);
const uploadSpeed = ref('0 MB/s');
const timeRemaining = ref('');
let uploadAbortController: AbortController | null = null;
let lastProgressTime = Date.now();
let lastProgressBytes = 0;
// Watch file size changes to auto-enable/disable scanning and captcha
watch(selectedFile, (file) => {
if (file) {
// Auto-enable scanning for files ≤50MB
// For files >50MB, user must manually enable
if (file.size <= 50 * 1024 * 1024) {
enableScan.value = true;
} else {
enableScan.value = false;
}
// Auto-enable CAPTCHA for files >50MB (for bot protection)
// User can still disable it if they want
if (file.size > 50 * 1024 * 1024) {
requireCaptcha.value = true;
isCaptchaAutoEnabled.value = true;
} else {
// Don't auto-disable if user manually enabled it for small files
if (isCaptchaAutoEnabled.value) {
requireCaptcha.value = false;
isCaptchaAutoEnabled.value = false;
}
}
}
});
// Watch enableScan toggle - trigger scan when manually enabled for large files
watch(enableScan, async (newValue, oldValue) => {
// Only trigger scan if:
// 1. Toggle changed from false to true (user manually enabled)
// 2. File is selected
// 3. File hasn't been scanned yet or was previously skipped
if (newValue && !oldValue && selectedFile.value && sha256Hash.value) {
if (scanStatus.value === 'skipped' || scanStatus.value === null) {
await performScan();
}
}
});
// Watch requireCaptcha toggle - clear auto-enabled flag when user manually changes it
watch(requireCaptcha, (newValue, oldValue) => {
// If user manually disables an auto-enabled captcha, clear the auto-enabled flag
if (!newValue && isCaptchaAutoEnabled.value) {
isCaptchaAutoEnabled.value = false;
}
});
const triggerFileInput = (event: MouseEvent) => {
// Don't trigger if clicking on the remove button
const target = event.target as HTMLElement;
if (target.closest('button')) {
return;
}
fileInput.value?.click();
};
const handleFileSelect = async (event: Event) => {
const target = event.target as HTMLInputElement;
if (target.files && target.files[0]) {
await processFile(target.files[0]);
}
};
const handleDrop = async (event: DragEvent) => {
isDragging.value = false;
if (event.dataTransfer?.files && event.dataTransfer.files[0]) {
await processFile(event.dataTransfer.files[0]);
}
};
// Perform malware scan on the currently selected file
const performScan = async () => {
if (!selectedFile.value || !sha256Hash.value) return;
// Reset scan state
scanStatus.value = 'pending';
virusDetails.value = '';
scanSkipReason.value = '';
isScanning.value = true;
try {
// Call actual scan API and ensure minimum scanning duration for UX
const [scanResult] = await Promise.all([
scanFileBeforeUpload(selectedFile.value, sha256Hash.value),
new Promise(resolve => setTimeout(resolve, 2000)) // Minimum 2s scanning animation
]);
if (scanResult.decision === 'infected' || scanResult.decision === 'suspicious') {
scanStatus.value = 'malicious';
// Build detailed virus information
const virusName = scanResult.clamav?.virus || 'Unknown threat';
const vtInfo = scanResult.virustotal
? ` (${scanResult.virustotal.positives}/${scanResult.virustotal.total} engines detected threats)`
: '';
virusDetails.value = scanResult.clamav?.infected
? `Virus Detected: ${virusName}${vtInfo}`
: `Suspicious File: Security scan flagged this file${vtInfo}`;
} else {
scanStatus.value = 'clean';
}
isScanning.value = false;
} catch (scanError: any) {
console.error('Scan failed:', scanError);
isScanning.value = false;
// Handle different scan failure scenarios
if (scanError.response?.status === 413 || scanError.message?.includes('too large') || scanError.message?.includes('payload')) {
// File too large for scanning
console.warn('File too large for scanning');
scanStatus.value = 'malicious';
virusDetails.value = 'Scan error: This file is too large to scan. Our scanner cannot process files of this size.';
} else if (scanError.response?.status === 503 && scanError.response?.data?.code === 'SCANNER_UNAVAILABLE') {
// Scanner service unavailable
console.warn('Scanner unavailable, skipping scan');
scanStatus.value = 'skipped';
scanSkipReason.value = 'scanner_unavailable';
} else if (scanError.code === 'ERR_NETWORK' || scanError.message?.includes('Network Error')) {
// Network error
console.warn('Scanner service unavailable, proceeding without scan');
scanStatus.value = 'skipped';
scanSkipReason.value = 'scanner_unavailable';
} else if (scanError.response?.status === 504 || scanError.code === 'ECONNABORTED') {
// Timeout - likely too large
console.warn('Scan timeout - file too large');
scanStatus.value = 'malicious';
virusDetails.value = 'Scan error: Scanning timed out. The file is too large to scan.';
} else {
// Other scan errors
scanStatus.value = 'malicious';
virusDetails.value = `Scan error: ${scanError.response?.data?.message || scanError.message || 'Unable to scan file. Please try again.'}`;
}
}
};
const processFile = async (file: File) => {
selectedFile.value = file;
scanStatus.value = null;
virusDetails.value = '';
isScanning.value = false;
scanSkipReason.value = '';
try {
// Compute SHA-256 hash
const hash = await computeSHA256(file);
sha256Hash.value = hash;
// Check if there's a resumable upload state for this file
const existingState = getResumableUploadState(hash);
if (existingState && existingState.shareCode) {
// File was previously being uploaded
uploadProgress.value = existingState.uploadProgress;
shareCode.value = existingState.shareCode;
isPaused.value = true; // Start in paused state so user can choose to resume
// Show notification
success(`📁 Found previous upload at ${existingState.uploadProgress}% - Click Resume to continue`);
return;
}
// Check if user disabled scanning
if (!enableScan.value) {
console.warn('Scanning disabled by user');
scanSkipReason.value = 'user_disabled';
isScanning.value = false;
scanStatus.value = 'skipped';
return;
}
// Start pre-upload scan (uses appropriate scanner based on file size)
// Files ≤32MB use fast API-based scanning
// Files >32MB use ClamAV scanner
await performScan();
} catch (err) {
console.error('Failed to process file:', err);
isScanning.value = false;
}
};
// Pause upload
const pauseUpload = () => {
// Immediately abort network request
if (uploadAbortController) {
uploadAbortController.abort();
uploadAbortController = null;
}
// IMMEDIATELY freeze the state - no async operations
isPaused.value = true;
isUploading.value = false; // Stop the upload state
uploadSpeed.value = '0 MB/s';
timeRemaining.value = '';
// Manually pause Lottie animation immediately
if (uploadLottieRef.value) {
try {
uploadLottieRef.value.pause();
} catch (e) {
// Silently fail if pause method not available
}
}
// Force Vue to update DOM immediately to freeze progress bar
// This ensures the CSS transition is removed before any more updates
Promise.resolve().then(() => {
// Save paused state after DOM update
if (sha256Hash.value) {
setUploadPaused(sha256Hash.value, true);
}
});
};
// Resume upload
const resumeUpload = async () => {
if (!selectedFile.value || !sha256Hash.value) return;
isPaused.value = false;
// Manually resume Lottie animation immediately
if (uploadLottieRef.value) {
try {
uploadLottieRef.value.play();
} catch (e) {
// Silently fail if play method not available
}
}
// Update paused state
setUploadPaused(sha256Hash.value, false);
// Continue upload from where it was paused
await uploadFile();
};
// Calculate upload speed and time remaining
const updateUploadStats = (bytesUploaded: number) => {
const now = Date.now();
const timeDiff = (now - lastProgressTime) / 1000; //seconds
const bytesDiff = bytesUploaded - lastProgressBytes;
if (timeDiff > 0) {
const bytesPerSecond = bytesDiff / timeDiff;
const mbPerSecond = bytesPerSecond / (1024 * 1024);
uploadSpeed.value = `${mbPerSecond.toFixed(2)} MB/s`;
if (selectedFile.value && bytesPerSecond > 0) {
const remainingBytes = selectedFile.value.size - bytesUploaded;
const remainingSeconds = remainingBytes / bytesPerSecond;
if (remainingSeconds < 60) {
timeRemaining.value = `${Math.ceil(remainingSeconds)}s remaining`;
} else if (remainingSeconds < 3600) {
timeRemaining.value = `${Math.ceil(remainingSeconds / 60)}m remaining`;
} else {
const hours = Math.floor(remainingSeconds / 3600);
const minutes = Math.ceil((remainingSeconds % 3600) / 60);
timeRemaining.value = `${hours}h ${minutes}m remaining`;
}
}
lastProgressTime = now;
lastProgressBytes = bytesUploaded;
}
};
const uploadFile = async () => {
if (!selectedFile.value || !sha256Hash.value) return;
// Check if this is a resume from an existing state
const existingState = getResumableUploadState(sha256Hash.value);
const isResuming = existingState && existingState.shareCode;
if (!isResuming) {
// Fresh upload - check scan status
if (isUploading.value) return; // Prevent double upload
if (scanStatus.value !== 'clean' && scanStatus.value !== 'skipped') return;
}
isUploading.value = true;
// Restore progress if resuming
if (isResuming) {
uploadProgress.value = existingState.uploadProgress;
shareCode.value = existingState.shareCode;
} else {
uploadProgress.value = 0;
uploadComplete.value = false;
}
isPaused.value = false;
uploadSpeed.value = '0 MB/s';
timeRemaining.value = '';
lastProgressTime = Date.now();
lastProgressBytes = 0;
uploadAbortController = new AbortController();
try {
// Request upload metadata (or reuse existing for resume)
if (!isResuming) {
const metaResponse = await uploadFileMeta({
filename: selectedFile.value.name,
size: selectedFile.value.size,