s3_swf_upload 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/CHANGELOG +26 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +20 -0
- data/Manifest +34 -0
- data/README.textile +223 -0
- data/Rakefile +14 -0
- data/flex_src/bin-release/flex-config.xml +361 -0
- data/flex_src/compile +2 -0
- data/flex_src/src/Globals.as +15 -0
- data/flex_src/src/S3Uploader.as +204 -0
- data/flex_src/src/com/adobe/net/MimeTypeMap.as +196 -0
- data/flex_src/src/com/elctech/S3UploadOptions.as +32 -0
- data/flex_src/src/com/elctech/S3UploadRequest.as +259 -0
- data/flex_src/src/com/nathancolgate/s3_swf_upload/BrowseButton.as +55 -0
- data/flex_src/src/com/nathancolgate/s3_swf_upload/S3Queue.as +117 -0
- data/flex_src/src/com/nathancolgate/s3_swf_upload/S3Signature.as +118 -0
- data/flex_src/src/com/nathancolgate/s3_swf_upload/S3Upload.as +111 -0
- data/lib/patch/integer.rb +12 -0
- data/lib/s3_swf_upload/railtie.rb +16 -0
- data/lib/s3_swf_upload/railties/generators/s3_swf_upload.rb +19 -0
- data/lib/s3_swf_upload/railties/generators/uploader/USAGE +10 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/amazon_s3.yml +20 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_down_button.gif +0 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_over_button.gif +0 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_up_button.gif +0 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_upload.js +118 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_upload.swf +0 -0
- data/lib/s3_swf_upload/railties/generators/uploader/templates/s3_uploads_controller.rb +53 -0
- data/lib/s3_swf_upload/railties/generators/uploader/uploader_generator.rb +20 -0
- data/lib/s3_swf_upload/railties/tasks/crossdomain.xml +5 -0
- data/lib/s3_swf_upload/s3_config.rb +43 -0
- data/lib/s3_swf_upload/signature.rb +203 -0
- data/lib/s3_swf_upload/view_helpers.rb +171 -0
- data/lib/s3_swf_upload.rb +10 -0
- data/s3_swf_upload.gemspec +29 -0
- metadata +103 -0
@@ -0,0 +1,361 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
|
3
|
+
<!--
|
4
|
+
|
5
|
+
ADOBE SYSTEMS INCORPORATED
|
6
|
+
Copyright 2005-2007 Adobe Systems Incorporated
|
7
|
+
All Rights Reserved.
|
8
|
+
|
9
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file
|
10
|
+
in accordance with the terms of the license agreement accompanying it.
|
11
|
+
|
12
|
+
-->
|
13
|
+
|
14
|
+
<flex-config>
|
15
|
+
<!-- Specifies the minimum player version that will run the compiled SWF. -->
|
16
|
+
<!-- 9.0.124 is the April 2008 security release -->
|
17
|
+
<target-player>9.0.124</target-player>
|
18
|
+
<!-- <target-player>11.1</target-player> -->
|
19
|
+
<compiler>
|
20
|
+
|
21
|
+
<!-- Turn on generation of accessible SWFs. -->
|
22
|
+
<accessible>false</accessible>
|
23
|
+
|
24
|
+
<!-- Specifies the locales for internationalization. -->
|
25
|
+
<locale>
|
26
|
+
<locale-element>en_US</locale-element>
|
27
|
+
</locale>
|
28
|
+
|
29
|
+
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
|
30
|
+
<source-path>
|
31
|
+
<path-element>../src</path-element>
|
32
|
+
</source-path>
|
33
|
+
|
34
|
+
<!-- Allow the source-path to have path-elements which contain other path-elements -->
|
35
|
+
<allow-source-path-overlap>false</allow-source-path-overlap>
|
36
|
+
|
37
|
+
<!-- Run the AS3 compiler in a mode that detects legal but potentially incorrect -->
|
38
|
+
<!-- code. -->
|
39
|
+
<show-actionscript-warnings>true</show-actionscript-warnings>
|
40
|
+
|
41
|
+
<!-- Turn on generation of debuggable SWFs. False by default for mxmlc, -->
|
42
|
+
<!-- but true by default for compc. -->
|
43
|
+
<!--
|
44
|
+
<debug>true</debug>
|
45
|
+
-->
|
46
|
+
|
47
|
+
<!-- List of SWC files or directories to compile against but to omit from -->
|
48
|
+
<!-- linking. -->
|
49
|
+
<external-library-path>
|
50
|
+
<!-- <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}/playerglobal.swc</path-element> -->
|
51
|
+
<path-element>${flexlib}/libs/player/11.1/playerglobal.swc</path-element>
|
52
|
+
|
53
|
+
</external-library-path>
|
54
|
+
|
55
|
+
<!-- Turn on writing of generated/*.as files to disk. These files are generated by -->
|
56
|
+
<!-- the compiler during mxml translation and are helpful with understanding and -->
|
57
|
+
<!-- debugging Flex applications. -->
|
58
|
+
<keep-generated-actionscript>false</keep-generated-actionscript>
|
59
|
+
|
60
|
+
<!-- not set -->
|
61
|
+
<!--
|
62
|
+
<include-libraries>
|
63
|
+
<library>string</library>
|
64
|
+
</include-libraries>
|
65
|
+
-->
|
66
|
+
|
67
|
+
<!-- List of SWC files or directories that contain SWC files. -->
|
68
|
+
<library-path>
|
69
|
+
<path-element>${flexlib}/libs</path-element>
|
70
|
+
<!-- keep the original location in the libpath for backwards-compatibility -->
|
71
|
+
<path-element>${flexlib}/libs/player</path-element>
|
72
|
+
|
73
|
+
<path-element>${flexlib}/libs/player/11.1</path-element>
|
74
|
+
<!-- <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}</path-element> -->
|
75
|
+
|
76
|
+
<path-element>${flexlib}/locale/{locale}</path-element>
|
77
|
+
</library-path>
|
78
|
+
|
79
|
+
<namespaces>
|
80
|
+
<!-- Specify a URI to associate with a manifest of components for use as MXML -->
|
81
|
+
<!-- elements. -->
|
82
|
+
<namespace>
|
83
|
+
<uri>http://www.adobe.com/2006/mxml</uri>
|
84
|
+
<manifest>${flexlib}/mxml-manifest.xml</manifest>
|
85
|
+
</namespace>
|
86
|
+
</namespaces>
|
87
|
+
|
88
|
+
<!-- Enable post-link SWF optimization. -->
|
89
|
+
<optimize>true</optimize>
|
90
|
+
|
91
|
+
<!-- Keep the following AS3 metadata in the bytecodes. -->
|
92
|
+
<!-- Warning: For the data binding feature in the Flex framework to work properly, -->
|
93
|
+
<!-- the following metadata must be kept: -->
|
94
|
+
<!-- 1. Bindable -->
|
95
|
+
<!-- 2. Managed -->
|
96
|
+
<!-- 3. ChangeEvent -->
|
97
|
+
<!-- 4. NonCommittingChangeEvent -->
|
98
|
+
<!-- 5. Transient -->
|
99
|
+
<!--
|
100
|
+
<keep-as3-metadata>
|
101
|
+
<name>Bindable</name>
|
102
|
+
<name>Managed</name>
|
103
|
+
<name>ChangeEvent</name>
|
104
|
+
<name>NonCommittingChangeEvent</name>
|
105
|
+
<name>Transient</name>
|
106
|
+
</keep-as3-metadata>
|
107
|
+
-->
|
108
|
+
|
109
|
+
<!-- Turn on reporting of data binding warnings. For example: Warning: Data binding -->
|
110
|
+
<!-- will not be able to detect assignments to "foo". -->
|
111
|
+
<show-binding-warnings>true</show-binding-warnings>
|
112
|
+
|
113
|
+
<!-- toggle whether warnings generated from unused type selectors are displayed -->
|
114
|
+
<show-unused-type-selector-warnings>true</show-unused-type-selector-warnings>
|
115
|
+
|
116
|
+
<!-- Run the AS3 compiler in strict error checking mode. -->
|
117
|
+
<strict>true</strict>
|
118
|
+
|
119
|
+
<!-- Use the ActionScript 3 class based object model for greater performance and better error reporting. -->
|
120
|
+
<!-- In the class based object model most built-in functions are implemented as fixed methods of classes -->
|
121
|
+
<!-- (-strict is recommended, but not required, for earlier errors) -->
|
122
|
+
<as3>true</as3>
|
123
|
+
|
124
|
+
<!-- Use the ECMAScript edition 3 prototype based object model to allow dynamic overriding of prototype -->
|
125
|
+
<!-- properties. In the prototype based object model built-in functions are implemented as dynamic -->
|
126
|
+
<!-- properties of prototype objects (-strict is allowed, but may result in compiler errors for -->
|
127
|
+
<!-- references to dynamic properties) -->
|
128
|
+
<es>false</es>
|
129
|
+
|
130
|
+
<!-- List of CSS or SWC files to apply as a theme. -->
|
131
|
+
<!-- not set -->
|
132
|
+
<!--
|
133
|
+
<theme>
|
134
|
+
<filename>string</filename>
|
135
|
+
<filename>string</filename>
|
136
|
+
</theme>
|
137
|
+
-->
|
138
|
+
|
139
|
+
<!-- Turns on the display of stack traces for uncaught runtime errors. -->
|
140
|
+
<verbose-stacktraces>false</verbose-stacktraces>
|
141
|
+
|
142
|
+
<!-- Defines the AS3 file encoding. -->
|
143
|
+
<!-- not set -->
|
144
|
+
<!--
|
145
|
+
<actionscript-file-encoding></actionscript-file-encoding>
|
146
|
+
-->
|
147
|
+
|
148
|
+
<fonts>
|
149
|
+
|
150
|
+
<!-- Enables advanced anti-aliasing for embedded fonts, which provides greater clarity for small -->
|
151
|
+
<!-- fonts. This setting can be overriden in CSS for specific fonts. -->
|
152
|
+
<!-- NOTE: flash-type has been deprecated. Please use advanced-anti-aliasing <flash-type>true</flash-type> -->
|
153
|
+
<advanced-anti-aliasing>true</advanced-anti-aliasing>
|
154
|
+
|
155
|
+
<!-- The number of embedded font faces that are cached. -->
|
156
|
+
<max-cached-fonts>20</max-cached-fonts>
|
157
|
+
|
158
|
+
<!-- The number of character glyph outlines to cache for each font face. -->
|
159
|
+
<max-glyphs-per-face>1000</max-glyphs-per-face>
|
160
|
+
|
161
|
+
<!-- Defines ranges that can be used across multiple font-face declarations. -->
|
162
|
+
<!-- See flash-unicode-table.xml for more examples. -->
|
163
|
+
<!-- not set -->
|
164
|
+
<!--
|
165
|
+
<languages>
|
166
|
+
<language-range>
|
167
|
+
<lang>englishRange</lang>
|
168
|
+
<range>U+0020-U+007E</range>
|
169
|
+
</language-range>
|
170
|
+
</languages>
|
171
|
+
-->
|
172
|
+
|
173
|
+
<!-- Compiler font manager classes, in policy resolution order-->
|
174
|
+
<managers>
|
175
|
+
<manager-class>flash.fonts.JREFontManager</manager-class>
|
176
|
+
<manager-class>flash.fonts.AFEFontManager</manager-class>
|
177
|
+
<manager-class>flash.fonts.BatikFontManager</manager-class>
|
178
|
+
</managers>
|
179
|
+
|
180
|
+
<!-- File containing cached system font licensing information produced via
|
181
|
+
java -cp mxmlc.jar flex2.tools.FontSnapshot (fontpath)
|
182
|
+
Will default to winFonts.ser on Windows XP and
|
183
|
+
macFonts.ser on Mac OS X, so is commented out by default.
|
184
|
+
|
185
|
+
<local-fonts-snapshot>localFonts.ser</local-fonts-snapshot>
|
186
|
+
-->
|
187
|
+
|
188
|
+
</fonts>
|
189
|
+
|
190
|
+
<!-- Array.toString() format has changed. -->
|
191
|
+
<warn-array-tostring-changes>false</warn-array-tostring-changes>
|
192
|
+
|
193
|
+
<!-- Assignment within conditional. -->
|
194
|
+
<warn-assignment-within-conditional>true</warn-assignment-within-conditional>
|
195
|
+
|
196
|
+
<!-- Possibly invalid Array cast operation. -->
|
197
|
+
<warn-bad-array-cast>true</warn-bad-array-cast>
|
198
|
+
|
199
|
+
<!-- Non-Boolean value used where a Boolean value was expected. -->
|
200
|
+
<warn-bad-bool-assignment>true</warn-bad-bool-assignment>
|
201
|
+
|
202
|
+
<!-- Invalid Date cast operation. -->
|
203
|
+
<warn-bad-date-cast>true</warn-bad-date-cast>
|
204
|
+
|
205
|
+
<!-- Unknown method. -->
|
206
|
+
<warn-bad-es3-type-method>true</warn-bad-es3-type-method>
|
207
|
+
|
208
|
+
<!-- Unknown property. -->
|
209
|
+
<warn-bad-es3-type-prop>true</warn-bad-es3-type-prop>
|
210
|
+
|
211
|
+
<!-- Illogical comparison with NaN. Any comparison operation involving NaN will evaluate to false because NaN != NaN. -->
|
212
|
+
<warn-bad-nan-comparison>true</warn-bad-nan-comparison>
|
213
|
+
|
214
|
+
<!-- Impossible assignment to null. -->
|
215
|
+
<warn-bad-null-assignment>true</warn-bad-null-assignment>
|
216
|
+
|
217
|
+
<!-- Illogical comparison with null. -->
|
218
|
+
<warn-bad-null-comparison>true</warn-bad-null-comparison>
|
219
|
+
|
220
|
+
<!-- Illogical comparison with undefined. Only untyped variables (or variables of type *) can be undefined. -->
|
221
|
+
<warn-bad-undefined-comparison>true</warn-bad-undefined-comparison>
|
222
|
+
|
223
|
+
<!-- Boolean() with no arguments returns false in ActionScript 3.0. Boolean() returned undefined in ActionScript 2.0. -->
|
224
|
+
<warn-boolean-constructor-with-no-args>false</warn-boolean-constructor-with-no-args>
|
225
|
+
|
226
|
+
<!-- __resolve is no longer supported. -->
|
227
|
+
<warn-changes-in-resolve>false</warn-changes-in-resolve>
|
228
|
+
|
229
|
+
<!-- Class is sealed. It cannot have members added to it dynamically. -->
|
230
|
+
<warn-class-is-sealed>true</warn-class-is-sealed>
|
231
|
+
|
232
|
+
<!-- Constant not initialized. -->
|
233
|
+
<warn-const-not-initialized>true</warn-const-not-initialized>
|
234
|
+
|
235
|
+
<!-- Function used in new expression returns a value. Result will be what the -->
|
236
|
+
<!-- function returns, rather than a new instance of that function. -->
|
237
|
+
<warn-constructor-returns-value>false</warn-constructor-returns-value>
|
238
|
+
|
239
|
+
<!-- EventHandler was not added as a listener. -->
|
240
|
+
<warn-deprecated-event-handler-error>false</warn-deprecated-event-handler-error>
|
241
|
+
|
242
|
+
<!-- Unsupported ActionScript 2.0 function. -->
|
243
|
+
<warn-deprecated-function-error>true</warn-deprecated-function-error>
|
244
|
+
|
245
|
+
<!-- Unsupported ActionScript 2.0 property. -->
|
246
|
+
<warn-deprecated-property-error>true</warn-deprecated-property-error>
|
247
|
+
|
248
|
+
<!-- More than one argument by the same name. -->
|
249
|
+
<warn-duplicate-argument-names>true</warn-duplicate-argument-names>
|
250
|
+
|
251
|
+
<!-- Duplicate variable definition -->
|
252
|
+
<warn-duplicate-variable-def>true</warn-duplicate-variable-def>
|
253
|
+
|
254
|
+
<!-- ActionScript 3.0 iterates over an object's properties within a "for x in target" statement in random order. -->
|
255
|
+
<warn-for-var-in-changes>false</warn-for-var-in-changes>
|
256
|
+
|
257
|
+
<!-- Importing a package by the same name as the current class will hide that class identifier in this scope. -->
|
258
|
+
<warn-import-hides-class>true</warn-import-hides-class>
|
259
|
+
|
260
|
+
<!-- Use of the instanceof operator. -->
|
261
|
+
<warn-instance-of-changes>true</warn-instance-of-changes>
|
262
|
+
|
263
|
+
<!-- Internal error in compiler. -->
|
264
|
+
<warn-internal-error>true</warn-internal-error>
|
265
|
+
|
266
|
+
<!-- _level is no longer supported. For more information, see the flash.display package. -->
|
267
|
+
<warn-level-not-supported>true</warn-level-not-supported>
|
268
|
+
|
269
|
+
<!-- Missing namespace declaration (e.g. variable is not defined to be public, private, etc.). -->
|
270
|
+
<warn-missing-namespace-decl>true</warn-missing-namespace-decl>
|
271
|
+
|
272
|
+
<!-- Negative value will become a large positive value when assigned to a uint data type. -->
|
273
|
+
<warn-negative-uint-literal>true</warn-negative-uint-literal>
|
274
|
+
|
275
|
+
<!-- Missing constructor. -->
|
276
|
+
<warn-no-constructor>false</warn-no-constructor>
|
277
|
+
|
278
|
+
<!-- The super() statement was not called within the constructor. -->
|
279
|
+
<warn-no-explicit-super-call-in-constructor>false</warn-no-explicit-super-call-in-constructor>
|
280
|
+
|
281
|
+
<!-- Missing type declaration. -->
|
282
|
+
<warn-no-type-decl>true</warn-no-type-decl>
|
283
|
+
|
284
|
+
<!-- In ActionScript 3.0, white space is ignored and '' returns 0. Number() returns -->
|
285
|
+
<!-- NaN in ActionScript 2.0 when the parameter is '' or contains white space. -->
|
286
|
+
<warn-number-from-string-changes>false</warn-number-from-string-changes>
|
287
|
+
|
288
|
+
<!-- Change in scoping for the this keyword. Class methods extracted from an -->
|
289
|
+
<!-- instance of a class will always resolve this back to that instance. In -->
|
290
|
+
<!-- ActionScript 2.0 this is looked up dynamically based on where the method -->
|
291
|
+
<!-- is invoked from. -->
|
292
|
+
<warn-scoping-change-in-this>false</warn-scoping-change-in-this>
|
293
|
+
|
294
|
+
<!-- Inefficient use of += on a TextField.-->
|
295
|
+
<warn-slow-text-field-addition>true</warn-slow-text-field-addition>
|
296
|
+
|
297
|
+
<!-- Possible missing parentheses. -->
|
298
|
+
<warn-unlikely-function-value>true</warn-unlikely-function-value>
|
299
|
+
|
300
|
+
<!-- Possible usage of the ActionScript 2.0 XML class. -->
|
301
|
+
<warn-xml-class-has-changed>false</warn-xml-class-has-changed>
|
302
|
+
|
303
|
+
</compiler>
|
304
|
+
|
305
|
+
<!-- compute-digest: writes a digest to the catalog.xml of a library. Use this when the library will be used as a
|
306
|
+
cross-domain rsl.-->
|
307
|
+
<!-- compute-digest usage:
|
308
|
+
<compute-digest>boolean</compute-digest>
|
309
|
+
-->
|
310
|
+
|
311
|
+
<!-- A list of runtime shared library URLs to be loaded before applications start. -->
|
312
|
+
<!-- not set -->
|
313
|
+
<!--
|
314
|
+
<runtime-shared-libraries>
|
315
|
+
<url>string</url>
|
316
|
+
<url>string</url>
|
317
|
+
</runtime-shared-libraries>
|
318
|
+
-->
|
319
|
+
|
320
|
+
<!-- runtime-shared-library-path: specifies a SWC or directory to link against and an RSL URL to load with optional failover URLs -->
|
321
|
+
<runtime-shared-library-path>
|
322
|
+
<path-element>libs/framework.swc</path-element>
|
323
|
+
<rsl-url>framework_3.4.0.9271.swz</rsl-url>
|
324
|
+
<policy-file-url></policy-file-url>
|
325
|
+
<rsl-url>framework_3.4.0.9271.swf</rsl-url>
|
326
|
+
<policy-file-url></policy-file-url>
|
327
|
+
</runtime-shared-library-path>
|
328
|
+
<!-- static-link-runtime-shared-libraries: statically link the libraries specified by the -runtime-shared-libraries-path option.-->
|
329
|
+
<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
|
330
|
+
|
331
|
+
<!-- target-player: specifies the version of the player the application is targeting.
|
332
|
+
Features requiring a later version will not be compiled into the application.
|
333
|
+
The minimum value supported is "9.0.0".-->
|
334
|
+
<!-- target-player usage:
|
335
|
+
<target-player>version</target-player>
|
336
|
+
-->
|
337
|
+
|
338
|
+
<!-- Enables SWFs to access the network. -->
|
339
|
+
<use-network>true</use-network>
|
340
|
+
|
341
|
+
<!-- Metadata added to SWFs via the SWF Metadata tag. -->
|
342
|
+
<metadata>
|
343
|
+
<title>Adobe Flex 3 Application</title>
|
344
|
+
<description>http://www.adobe.com/products/flex</description>
|
345
|
+
<publisher>unknown</publisher>
|
346
|
+
<creator>unknown</creator>
|
347
|
+
<language>EN</language>
|
348
|
+
</metadata>
|
349
|
+
|
350
|
+
<!-- licenses: specifies a list of product and serial number pairs. -->
|
351
|
+
<!-- not set -->
|
352
|
+
<!--
|
353
|
+
<licenses>
|
354
|
+
<license>
|
355
|
+
<product>string</product>
|
356
|
+
<serial-number>number</serial-number>
|
357
|
+
</license>
|
358
|
+
</licenses>
|
359
|
+
-->
|
360
|
+
|
361
|
+
</flex-config>
|
data/flex_src/compile
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
package {
|
2
|
+
|
3
|
+
import flash.events.*;
|
4
|
+
import flash.external.*;
|
5
|
+
import flash.net.*;
|
6
|
+
import flash.display.*;
|
7
|
+
import flash.system.Security;
|
8
|
+
import com.nathancolgate.s3_swf_upload.*;
|
9
|
+
|
10
|
+
public class S3Uploader extends Sprite {
|
11
|
+
|
12
|
+
//File Reference Vars
|
13
|
+
public var queue:S3Queue;
|
14
|
+
public var file:FileReference;
|
15
|
+
|
16
|
+
private var _multipleFileDialogBox:FileReferenceList;
|
17
|
+
private var _singleFileDialogBox:FileReference;
|
18
|
+
private var _fileFilter:FileFilter;
|
19
|
+
|
20
|
+
//config vars
|
21
|
+
private var _fileSizeLimit:Number; //bytes
|
22
|
+
private var _queueSizeLimit:Number;
|
23
|
+
private var _selectMultipleFiles:Boolean;
|
24
|
+
|
25
|
+
private var cssLoader:URLLoader;
|
26
|
+
public static var s3_swf_obj:String;
|
27
|
+
|
28
|
+
public function S3Uploader() {
|
29
|
+
super();
|
30
|
+
S3Uploader.s3_swf_obj = LoaderInfo(root.loaderInfo).parameters.s3_swf_obj;
|
31
|
+
registerCallbacks();
|
32
|
+
}
|
33
|
+
|
34
|
+
private function registerCallbacks():void {
|
35
|
+
if (ExternalInterface.available) {
|
36
|
+
ExternalInterface.addCallback("init", init);
|
37
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.init');
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
private function init(signatureUrl:String,
|
42
|
+
prefixPath:String,
|
43
|
+
fileSizeLimit:Number,
|
44
|
+
queueSizeLimit:Number,
|
45
|
+
fileTypes:String,
|
46
|
+
fileTypeDescs:String,
|
47
|
+
selectMultipleFiles:Boolean,
|
48
|
+
buttonWidth:Number,
|
49
|
+
buttonHeight:Number,
|
50
|
+
buttonUpUrl:String,
|
51
|
+
buttonDownUrl:String,
|
52
|
+
buttonOverUrl:String
|
53
|
+
):void {
|
54
|
+
// ExternalInterface.call('s3_swf.jsLog','Initializing...');
|
55
|
+
|
56
|
+
flash.system.Security.allowDomain("*");
|
57
|
+
|
58
|
+
// UI
|
59
|
+
var browseButton:BrowseButton = new BrowseButton(buttonWidth,buttonHeight,buttonUpUrl,buttonDownUrl,buttonOverUrl);
|
60
|
+
addChild(browseButton);
|
61
|
+
|
62
|
+
|
63
|
+
stage.showDefaultContextMenu = false;
|
64
|
+
stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
|
65
|
+
stage.align = flash.display.StageAlign.TOP_LEFT;
|
66
|
+
|
67
|
+
this.addEventListener(MouseEvent.CLICK, clickHandler);
|
68
|
+
|
69
|
+
// file dialog boxes
|
70
|
+
// We do two, so that we have the option to pick one or many
|
71
|
+
_fileSizeLimit = fileSizeLimit;
|
72
|
+
_fileFilter = new FileFilter(fileTypeDescs, fileTypes);
|
73
|
+
_queueSizeLimit = queueSizeLimit;
|
74
|
+
_selectMultipleFiles = selectMultipleFiles;
|
75
|
+
_multipleFileDialogBox = new FileReferenceList;
|
76
|
+
_singleFileDialogBox = new FileReference;
|
77
|
+
_multipleFileDialogBox.addEventListener(Event.SELECT, selectFileHandler);
|
78
|
+
_singleFileDialogBox.addEventListener(Event.SELECT, selectFileHandler);
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
// Setup Queue, File
|
83
|
+
this.queue = new S3Queue(signatureUrl,prefixPath);
|
84
|
+
Globals.queue = this.queue;
|
85
|
+
|
86
|
+
ExternalInterface.addCallback("removeFileFromQueue", removeFileHandler);
|
87
|
+
// ExternalInterface.call('s3_swf.jsLog','Initialized');
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
// called when the browse button is clicked
|
92
|
+
// Browse for files
|
93
|
+
private function clickHandler(event:Event):void{
|
94
|
+
// ExternalInterface.call('s3_swf.jsLog','clickHandler');
|
95
|
+
if(_selectMultipleFiles == true){
|
96
|
+
// ExternalInterface.call('s3_swf.jsLog','Opening Multiple File Dialog box...');
|
97
|
+
_multipleFileDialogBox.browse([_fileFilter]);
|
98
|
+
// ExternalInterface.call('s3_swf.jsLog','Multiple File Dialog box Opened');
|
99
|
+
} else {
|
100
|
+
// ExternalInterface.call('s3_swf.jsLog','Opening Single File Dialog box...');
|
101
|
+
_singleFileDialogBox.browse([_fileFilter]);
|
102
|
+
// ExternalInterface.call('s3_swf.jsLog','Single File Dialog box Opened');
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
// called after user selected files form the browse dialouge box.
|
107
|
+
private function selectFileHandler(event:Event):void {
|
108
|
+
// ExternalInterface.call('s3_swf.jsLog','selectFileHandler');
|
109
|
+
var remainingSpots:int = _queueSizeLimit - this.queue.length;
|
110
|
+
var tooMany:Boolean = false;
|
111
|
+
|
112
|
+
if(_selectMultipleFiles == true){
|
113
|
+
// Adding multiple files to the queue array
|
114
|
+
// ExternalInterface.call('s3_swf.jsLog','Adding multiple files to the queue array...');
|
115
|
+
if(event.currentTarget.fileList.length > remainingSpots) { tooMany = true; }
|
116
|
+
var i:int;
|
117
|
+
for (i=0;i < remainingSpots; i ++){
|
118
|
+
// ExternalInterface.call('s3_swf.jsLog','Adding '+(i+1)+' of '+(remainingSpots)+' files to the queue array...');
|
119
|
+
addFile(event.currentTarget.fileList[i]);
|
120
|
+
// ExternalInterface.call('s3_swf.jsLog',(i+1)+' of '+(remainingSpots)+' files added to the queue array');
|
121
|
+
}
|
122
|
+
// ExternalInterface.call('s3_swf.jsLog','Multiple files added to the queue array');
|
123
|
+
} else {
|
124
|
+
// Adding one single file to the queue array
|
125
|
+
// ExternalInterface.call('s3_swf.jsLog','Adding single file to the queue array...');
|
126
|
+
if(remainingSpots > 0) {
|
127
|
+
addFile(FileReference(event.target));
|
128
|
+
} else {
|
129
|
+
tooMany = true;
|
130
|
+
}
|
131
|
+
// ExternalInterface.call('s3_swf.jsLog','Single file added to the queue array');
|
132
|
+
}
|
133
|
+
|
134
|
+
if(tooMany == true) {
|
135
|
+
// ExternalInterface.call('s3_swf.jsLog','Calling onQueueSizeLimitReached...');
|
136
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.onQueueSizeLimitReached',this.queue.toJavascript());
|
137
|
+
// ExternalInterface.call('s3_swf.jsLog','onQueueSizeLimitReached called');
|
138
|
+
}
|
139
|
+
|
140
|
+
}
|
141
|
+
|
142
|
+
// Add Selected File to Queue from file browser dialog box
|
143
|
+
private function addFile(file:FileReference):void{
|
144
|
+
// ExternalInterface.call('s3_swf.jsLog','addFile');
|
145
|
+
if(!file) return;
|
146
|
+
if (checkFileSize(file.size)){
|
147
|
+
// ExternalInterface.call('s3_swf.jsLog','Adding file to queue...');
|
148
|
+
this.queue.addItem(file);
|
149
|
+
// ExternalInterface.call('s3_swf.jsLog','File added to queue');
|
150
|
+
// ExternalInterface.call('s3_swf.jsLog','Calling onFileAdd...');
|
151
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.onFileAdd',toJavascript(file));
|
152
|
+
// ExternalInterface.call('s3_swf.jsLog','onFileAdd called');
|
153
|
+
} else {
|
154
|
+
// ExternalInterface.call('s3_swf.jsLog','Calling onFileSizeLimitReached...');
|
155
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.onFileSizeLimitReached',toJavascript(file));
|
156
|
+
// ExternalInterface.call('s3_swf.jsLog','onFileSizeLimitReached called');
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
|
161
|
+
// Remove File From Queue by index number
|
162
|
+
private function removeFileHandler(index:Number):void{
|
163
|
+
try {
|
164
|
+
var del_file:FileReference = FileReference(this.queue.getItemAt(index));
|
165
|
+
this.queue.removeItemAt(index);
|
166
|
+
// ExternalInterface.call('s3_swf.jsLog','Calling onFileRemove...');
|
167
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.onFileRemove',del_file);
|
168
|
+
// ExternalInterface.call('s3_swf.jsLog','onFileRemove called');
|
169
|
+
} catch(e:Error) {
|
170
|
+
// ExternalInterface.call('s3_swf.jsLog','Calling onFileNotInQueue...');
|
171
|
+
ExternalInterface.call(S3Uploader.s3_swf_obj+'.onFileNotInQueue');
|
172
|
+
// ExternalInterface.call('s3_swf.jsLog','onFileNotInQueue called');
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
|
177
|
+
/* MISC */
|
178
|
+
|
179
|
+
// Checks the files do not exceed maxFileSize | if maxFileSize == 0 No File Limit Set
|
180
|
+
private function checkFileSize(filesize:Number):Boolean{
|
181
|
+
var r:Boolean = false;
|
182
|
+
//if filesize greater then maxFileSize
|
183
|
+
if (filesize > _fileSizeLimit){
|
184
|
+
r = false;
|
185
|
+
} else if (filesize <= _fileSizeLimit){
|
186
|
+
r = true;
|
187
|
+
}
|
188
|
+
if (_fileSizeLimit == 0){
|
189
|
+
r = true;
|
190
|
+
}
|
191
|
+
return r;
|
192
|
+
}
|
193
|
+
|
194
|
+
// Turns a FileReference into an Object so that ExternalInterface doesn't choke
|
195
|
+
private function toJavascript(file:FileReference):Object{
|
196
|
+
var javascriptable_file:Object = new Object();
|
197
|
+
javascriptable_file.name = file.name;
|
198
|
+
javascriptable_file.size = file.size;
|
199
|
+
javascriptable_file.type = file.type;
|
200
|
+
return javascriptable_file;
|
201
|
+
}
|
202
|
+
|
203
|
+
}
|
204
|
+
}
|