|
539 | 539 | <cfset var data = "" /> |
540 | 540 | <cfset var tmpfile = getCachedFile(config=arguments.config,file=arguments.file) /> |
541 | 541 |
|
542 | | - <cfif len(tmpfile)> |
| 542 | + <cftry> |
543 | 543 |
|
544 | | - <!--- Read cache file ---> |
545 | | - <cfswitch expression="#arguments.datatype#"> |
546 | | - <cfcase value="text"> |
547 | | - <cffile action="read" file="#tmpfile#" variable="data" /> |
548 | | - </cfcase> |
| 544 | + <cfif len(tmpfile)> |
549 | 545 |
|
550 | | - <cfcase value="binary"> |
551 | | - <cffile action="readBinary" file="#tmpfile#" variable="data" /> |
552 | | - </cfcase> |
| 546 | + <!--- Read cache file ---> |
| 547 | + <cfswitch expression="#arguments.datatype#"> |
| 548 | + <cfcase value="text"> |
| 549 | + <cffile action="read" file="#tmpfile#" variable="data" /> |
| 550 | + </cfcase> |
| 551 | + |
| 552 | + <cfcase value="binary"> |
| 553 | + <cffile action="readBinary" file="#tmpfile#" variable="data" /> |
| 554 | + </cfcase> |
| 555 | + |
| 556 | + <cfcase value="image"> |
| 557 | + <cfset data = imageread(tmpfile) /> |
| 558 | + </cfcase> |
| 559 | + </cfswitch> |
553 | 560 |
|
554 | | - <cfcase value="image"> |
555 | | - <cfset data = imageread(tmpfile) /> |
556 | | - </cfcase> |
557 | | - </cfswitch> |
558 | | - |
559 | | - <cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from local cache" /> |
560 | | - |
561 | | - <cfelse> |
| 561 | + <cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from local cache" /> |
| 562 | + |
| 563 | + <cfelse> |
562 | 564 |
|
563 | | - <cfset tmpfile = getTemporaryFile(config=arguments.config,file=arguments.file) /> |
564 | | - |
565 | | - <cfset ioCopyFile(source_config=arguments.config,source_file=arguments.file,dest_localpath=tmpfile) /> |
566 | | - |
567 | | - <!--- Read cache file ---> |
568 | | - <cfswitch expression="#arguments.datatype#"> |
569 | | - <cfcase value="text"> |
570 | | - <cffile action="read" file="#tmpfile#" variable="data" /> |
571 | | - </cfcase> |
| 565 | + <cfset tmpfile = getTemporaryFile(config=arguments.config,file=arguments.file) /> |
572 | 566 |
|
573 | | - <cfcase value="binary"> |
574 | | - <cffile action="readBinary" file="#tmpfile#" variable="data" /> |
575 | | - </cfcase> |
| 567 | + <cfset ioCopyFile(source_config=arguments.config,source_file=arguments.file,dest_localpath=tmpfile) /> |
| 568 | + |
| 569 | + <!--- Read cache file ---> |
| 570 | + <cfswitch expression="#arguments.datatype#"> |
| 571 | + <cfcase value="text"> |
| 572 | + <cffile action="read" file="#tmpfile#" variable="data" /> |
| 573 | + </cfcase> |
| 574 | + |
| 575 | + <cfcase value="binary"> |
| 576 | + <cffile action="readBinary" file="#tmpfile#" variable="data" /> |
| 577 | + </cfcase> |
| 578 | + |
| 579 | + <cfcase value="image"> |
| 580 | + <cfset data = imageread(tmpfile) /> |
| 581 | + </cfcase> |
| 582 | + </cfswitch> |
| 583 | + |
| 584 | + <cfif arguments.config.localCacheSize> |
| 585 | + <cfset addCachedFile(config=arguments.config,file=arguments.file,path=tmpfile) /> |
| 586 | + <cfelse> |
| 587 | + <!--- Delete temporary file ---> |
| 588 | + <cfset deleteTemporaryFile(tmpfile) /> |
| 589 | + </cfif> |
| 590 | + |
| 591 | + <cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from S3" /> |
576 | 592 |
|
577 | | - <cfcase value="image"> |
578 | | - <cfset data = imageread(tmpfile) /> |
579 | | - </cfcase> |
580 | | - </cfswitch> |
581 | | - |
582 | | - <cfif arguments.config.localCacheSize> |
583 | | - <cfset addCachedFile(config=arguments.config,file=arguments.file,path=tmpfile) /> |
584 | | - <cfelse> |
585 | | - <!--- Delete temporary file ---> |
586 | | - <cfset deleteTemporaryFile(tmpfile) /> |
587 | 593 | </cfif> |
588 | | - |
589 | | - <cflog file="#application.applicationname#_s3" text="Read [#arguments.config.name#] #sanitiseS3URL(arguments.file)# from S3" /> |
590 | | - |
591 | | - </cfif> |
| 594 | + |
| 595 | + <cfcatch> |
| 596 | + <cflog file="#application.applicationname#_s3" text="Error reading [#arguments.config.name#] #sanitiseS3URL(arguments.file)#: #cfcatch.message#" /> |
| 597 | + <cfrethrow> |
| 598 | + </cfcatch> |
| 599 | + </cftry> |
592 | 600 |
|
593 | 601 | <cfreturn data /> |
594 | 602 | </cffunction> |
|
0 commit comments