Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2F599200CC2 for ; Wed, 5 Jul 2017 11:04:56 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 2E098162BBD; Wed, 5 Jul 2017 09:04:56 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 4DAFC162BBA for ; Wed, 5 Jul 2017 11:04:55 +0200 (CEST) Received: (qmail 15252 invoked by uid 500); 5 Jul 2017 09:04:54 -0000 Mailing-List: contact commits-help@flex.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flex.apache.org Delivered-To: mailing list commits@flex.apache.org Received: (qmail 15244 invoked by uid 99); 5 Jul 2017 09:04:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Jul 2017 09:04:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5E2BFDFE22; Wed, 5 Jul 2017 09:04:54 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yishayw@apache.org To: commits@flex.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: git commit: [flex-asjs] [refs/heads/develop] - Added FileLoaderAndUploader to emulate FileReference.upload() Date: Wed, 5 Jul 2017 09:04:54 +0000 (UTC) archived-at: Wed, 05 Jul 2017 09:04:56 -0000 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 Authored: Wed Jul 5 12:04:11 2017 +0300 Committer: DESKTOP-RH4S838\Yishay 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 @@ +