ユーザーが Amazon S3 に画像をアップロードするためにトリガーできる自動ルーチンがあります。通常、ユーザーは 500 を超えるアイテムをアップロードするので、プロセスがタイムアウトしないようにする方法を見つけるのに苦労しています。
今、私はこれをやっています:
<form action="hs_import.cfm?ansicht=Bilder&RequestTimeout=5000" method="post" name="uploader">
...
<input type="button" OnClick="bilder_upload()" value="#tx_gen_run#">
<input type="hidden" name="artikel_uploaden" value="ja">
<input type="hidden" name="ansicht" value="imageloader">
</form>
私のアップロードをトリガーするjavascript関数をトリガーします(詳細はありません):
<cfif isdefined("artikel_uploaden")>
<cfscript>
S3 variables
</cfscript>
<!--- get img paths to upload --->
<cfquery datasource="db" name="img_paths">
SELECT DISTINCT imgpath
</cfquery>
<cfif img_paths.recordcount GT 0>
<cfloop query="img_paths">
<cfif img_paths.typ NEQ "img">
<cfset variables.testFilePath = img_paths.bildpfad & img_paths.bilddateiname>
<cfset variables.fileExt = ListLast(variables.testFilePath, ".")>
<!--- get image --->
<cfhttp timeout="45"
throwonerror="no"
url="#variables.testFilePath#"
method="get"
useragent="Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12"
getasbinary="yes"
result="variables.objGet">
<!--- validate --->
<!--- upload 4 sizes (s,m,l,xl) to S3 --->
<cftry>
<cfset objImage = ImageNew(variables.objGet.FileContent )>
<cfimage source="#objImage#" action="write" quality=".99" destination="#variables.tempDirectory#_base_#img_paths.bilddateiname#" overwrite="yes">
<cfset variables.basePath = variables.tempDirectory & "_base_" & img_paths.bilddateiname>
<cfimage action="read" source="#variables.basePath#" name="base">
<cfset variables.imageSrc = variables.tempDirectory>
<cfscript>
if ( ImageGetWidth( base ) LT ImageGetHeight( base ) ) {
// portrait
} else {
// landscape/square
}
// cleanup
</cfscript>
<!--- create IMG entry in media table --->
<cfquery datasource="db"></cfquery>
</cfif>
<cfcatch>
<cfset variables.errorCount = variables.errorCount+1>
<cfset variables.failedLoads = variables.failedLoads & img_paths.bilddateiname & " (" & tx_pop_error & ":" & tx_errors_import_ext & "), ">
</cfcatch>
</cftry>
</cfif>
</cfloop>
<!--- alert on success and errors --->
</cfif>
これは問題なく機能しますが、画像の数が多すぎるとブラウザがハングアップ/タイムアウトするため、通常、ロード画面が終了せず、成功/エラーを警告しません。
質問:
このような大きなファイルのアップロードを処理するより良い代替手段は何ですか? cfschedule
たとえば、バックグラウンドで実行できるように、これを に入れる必要がありますか?
ヒントをありがとう!