flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yish...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Added FileLoaderAndUploader to emulate FileReference.upload()
Date Wed, 05 Jul 2017 09:04:54 GMT
Repository: flex-asjs
Updated Branches:
  refs/heads/develop 73c18eccf -> 48f1fd801


Added FileLoaderAndUploader to emulate FileReference.upload()


Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/48f1fd80
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/48f1fd80
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/48f1fd80

Branch: refs/heads/develop
Commit: 48f1fd801a2d9ac8815b24f94894a594440394ed
Parents: 73c18ec
Author: DESKTOP-RH4S838\Yishay <yishayjobs@hotmail.com>
Authored: Wed Jul 5 12:04:11 2017 +0300
Committer: DESKTOP-RH4S838\Yishay <yishayjobs@hotmail.com>
Committed: Wed Jul 5 12:04:11 2017 +0300

----------------------------------------------------------------------
 .../flex/file/beads/FileLoaderAndUploader.as    | 95 ++++++++++++++++++++
 .../org/apache/flex/file/beads/FileUploader.as  |  4 +-
 .../src/main/resources/basic-manifest.xml       |  1 +
 3 files changed, 98 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/48f1fd80/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
b/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
new file mode 100644
index 0000000..77ba96c
--- /dev/null
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileLoaderAndUploader.as
@@ -0,0 +1,95 @@
+//
+//  Licensed to the Apache Software Foundation (ASF) under one or more
+//  contributor license agreements.  See the NOTICE file distributed with
+//  this work for additional information regarding copyright ownership.
+//  The ASF licenses this file to You under the Apache License, Version 2.0
+//  (the "License"); you may not use this file except in compliance with
+//  the License.  You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+//  Unless required by applicable law or agreed to in writing, software
+//  distributed under the License is distributed on an "AS IS" BASIS,
+//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+//  See the License for the specific language governing permissions and
+//  limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package org.apache.flex.file.beads
+{
+	import org.apache.flex.core.IStrand;
+	import org.apache.flex.events.Event;
+
+	/**
+	 *  The FileLoaderUploader is a compound bead that allows you
+	 *  to load a file and upload it in one operation.
+	 *  
+	 *
+	 *  @toplevel
+	 *  @langversion 3.0
+	 *  @playerversion Flash 10.2
+	 *  @playerversion AIR 2.6
+	 *  @productversion FlexJS 0.9
+	 */
+	public class FileLoaderAndUploader extends FileUploader
+	{
+		private var _loader:FileLoader;
+		private var _url:String;
+		public function FileLoaderAndUploader()
+		{
+			super();
+		}
+		
+		/**
+		 *  @copy org.apache.flex.core.IBead#strand
+		 *  
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.9
+		 */
+		override public function set strand(value:IStrand):void
+		{
+			super.strand = value;
+			_loader = value.getBeadByType(FileLoader) as FileLoader;
+			if (!_loader)
+			{
+				_loader = new FileLoader();
+				value.addBead(_loader);
+			}
+		}
+		
+		/**
+		 *  Upload a file to the specified url. If file hasn't been loaded already it will be.
+		 *
+		 *  @langversion 3.0
+		 *  @playerversion Flash 10.2
+		 *  @playerversion AIR 2.6
+		 *  @productversion FlexJS 0.9
+		 */
+		
+		override public function upload(url:String):void
+		{
+			var fileModel:FileModel = host.model as FileModel;
+			if (!fileModel.blob)
+			{
+				_url = url;
+				host.model.addEventListener("blobChanged", blobChangedHandler);
+				_loader.load();
+			} else
+			{
+				super.upload(url);
+			}
+		}
+		
+		/**
+		 * @private
+		 */
+		private function blobChangedHandler(e:Event):void
+		{
+			host.model.removeEventListener('blobChanged', blobChangedHandler);
+			super.upload(_url);
+		}
+		
+	}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/48f1fd80/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
b/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
index 804d569..0cf4d5f 100644
--- a/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/file/beads/FileUploader.as
@@ -53,7 +53,7 @@ package org.apache.flex.file.beads
 
 		
 		/**
-		 *  Open up the system file browser. A user selection will trigger a 'modelChanged' event
on the strand.
+		 *  Upload a file to the specified url.
 		 *
 		 *  @langversion 3.0
 		 *  @playerversion Flash 10.2
@@ -89,7 +89,7 @@ package org.apache.flex.file.beads
 		/**
 		 * @private
 		 */
-		private function get host():FileProxy
+		protected function get host():FileProxy
 		{
 			return _strand as FileProxy;
 		}

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/48f1fd80/frameworks/projects/Network/src/main/resources/basic-manifest.xml
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/resources/basic-manifest.xml b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
index 2222c62..eabda27 100644
--- a/frameworks/projects/Network/src/main/resources/basic-manifest.xml
+++ b/frameworks/projects/Network/src/main/resources/basic-manifest.xml
@@ -27,4 +27,5 @@
     <component id="FileBrowser" class="org.apache.flex.file.beads.FileBrowser"/>
     <component id="FileLoader" class="org.apache.flex.file.beads.FileLoader"/>
     <component id="FileUploader" class="org.apache.flex.file.beads.FileUploader"/>
+    <component id="FileLoaderAndUploader" class="org.apache.flex.file.beads.FileLoaderAndUploader"/>
 </componentPackage>


Mime
View raw message