@@ -169,13 +169,16 @@ const Forms = (props) => {
169
169
} ) ;
170
170
setIsDecrypting ( false ) ;
171
171
setfileload ( true ) ;
172
- if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
172
+ const fileAdapterId =
173
+ extUserData ?. TenantId ?. ActiveFileAdapter || "" ;
174
+ if ( fileAdapterId ) {
173
175
const base64 = await toDataUrl ( pdfFile ) ;
174
176
const fileBase64 = base64 . split ( "," ) . pop ( ) ;
175
177
const ext = files ?. [ 0 ] ?. name ?. split ( "." ) . pop ( ) ;
176
178
const fileRes = await saveToCustomFile (
177
179
fileBase64 ,
178
- `${ name } .${ ext } `
180
+ `${ name } .${ ext } ` ,
181
+ fileAdapterId
179
182
) ;
180
183
if ( fileRes . url ) {
181
184
setFileUpload ( fileRes . url ) ;
@@ -263,7 +266,9 @@ const Forms = (props) => {
263
266
} ) ;
264
267
const size = files ?. [ 0 ] ?. size ;
265
268
const name = generatePdfName ( 16 ) ;
266
- if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
269
+ const fileAdapterId =
270
+ extUserData ?. TenantId ?. ActiveFileAdapter || "" ;
271
+ if ( fileAdapterId ) {
267
272
const base64 = await pdfDoc . saveAsBase64 ( {
268
273
useObjectStreams : false
269
274
} ) ;
@@ -272,7 +277,8 @@ const Forms = (props) => {
272
277
const ext = files ?. [ 0 ] ?. name ?. split ( "." ) . pop ( ) ;
273
278
const fileRes = await saveToCustomFile (
274
279
fileBase64 ,
275
- `${ name } .${ ext } `
280
+ `${ name } .${ ext } ` ,
281
+ fileAdapterId
276
282
) ;
277
283
if ( fileRes . url ) {
278
284
setFileUpload ( fileRes . url ) ;
@@ -373,11 +379,12 @@ const Forms = (props) => {
373
379
}
374
380
} ;
375
381
376
- const saveToCustomFile = async ( base64 , filname ) => {
382
+ const saveToCustomFile = async ( base64 , filename , fileAdapterId ) => {
377
383
try {
378
384
const savetos3 = await Parse . Cloud . run ( "savetofileadapter" , {
379
385
fileBase64 : base64 ,
380
- fileName : filname
386
+ fileName : filename ,
387
+ id : fileAdapterId
381
388
} ) ;
382
389
return { url : savetos3 . url } ;
383
390
} catch ( err ) {
@@ -391,11 +398,16 @@ const Forms = (props) => {
391
398
const size = file . size ;
392
399
const name = generatePdfName ( 16 ) ;
393
400
const pdfFile = file ;
394
- if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
401
+ const fileAdapterId = extUserData ?. TenantId ?. ActiveFileAdapter || "" ;
402
+ if ( fileAdapterId ) {
395
403
const base64 = await toDataUrl ( file ) ;
396
404
const fileBase64 = base64 . split ( "," ) . pop ( ) ;
397
405
const ext = file ?. name ?. split ( "." ) . pop ( ) ;
398
- const fileRes = await saveToCustomFile ( fileBase64 , `${ name } .${ ext } ` ) ;
406
+ const fileRes = await saveToCustomFile (
407
+ fileBase64 ,
408
+ `${ name } .${ ext } ` ,
409
+ fileAdapterId
410
+ ) ;
399
411
if ( fileRes . url ) {
400
412
setFileUpload ( fileRes ?. url ) ;
401
413
const tenantId = localStorage . getItem ( "TenantId" ) ;
@@ -459,11 +471,16 @@ const Forms = (props) => {
459
471
return ;
460
472
} else {
461
473
const name = generatePdfName ( 16 ) ;
462
- if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
474
+ const fileAdapterId = extUserData ?. TenantId ?. ActiveFileAdapter || "" ;
475
+ if ( fileAdapterId ) {
463
476
const base64 = await uriToBase64 ( url ) ;
464
477
const fileBase64 = base64 . split ( "," ) . pop ( ) ;
465
478
const ext = file ?. name ?. split ( "." ) . pop ( ) ;
466
- const fileRes = await saveToCustomFile ( fileBase64 , `${ name } .${ ext } ` ) ;
479
+ const fileRes = await saveToCustomFile (
480
+ fileBase64 ,
481
+ `${ name } .${ ext } ` ,
482
+ fileAdapterId
483
+ ) ;
467
484
if ( fileRes . url ) {
468
485
setFileUpload ( fileRes . url ) ;
469
486
setfileload ( false ) ;
@@ -558,7 +575,7 @@ const Forms = (props) => {
558
575
objectId : ExtCls [ 0 ] . objectId
559
576
} ) ;
560
577
if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
561
- object . set ( "IsFileAdapter " , true ) ;
578
+ object . set ( "FileAdapterId " , extUserData ?. TenantId ?. ActiveFileAdapter ) ;
562
579
}
563
580
const res = await object . save ( ) ;
564
581
if ( res ) {
@@ -664,12 +681,17 @@ const Forms = (props) => {
664
681
type : "application/pdf"
665
682
} ) ;
666
683
setIsDecrypting ( false ) ;
684
+ const fileAdapterId = extUserData ?. TenantId ?. ActiveFileAdapter || "" ;
667
685
// Upload the file to Parse Server
668
- if ( extUserData ?. TenantId ?. ActiveFileAdapter ) {
686
+ if ( fileAdapterId ) {
669
687
const base64 = await toDataUrl ( pdfFile ) ;
670
688
const fileBase64 = base64 . split ( "," ) . pop ( ) ;
671
689
const ext = formData ?. file ?. name ?. split ( "." ) . pop ( ) ;
672
- const fileRes = await saveToCustomFile ( fileBase64 , `${ name } .${ ext } ` ) ;
690
+ const fileRes = await saveToCustomFile (
691
+ fileBase64 ,
692
+ `${ name } .${ ext } ` ,
693
+ fileAdapterId
694
+ ) ;
673
695
if ( fileRes . url ) {
674
696
setFormData ( ( prev ) => ( { ...prev , password : "" } ) ) ;
675
697
setFileUpload ( fileRes ?. url ) ;
0 commit comments