FileReference class
Afther all, I send you all my best greetings.
I have been trying an example of downloading a file from the server with the FileReference class in Flex (Action script 3). It works with files upto 4 Gb.
For larger files, the resulting downloaded file is incomplete.
I read in the Documentation that the member variable"size" should be defined as Number object. But in my developing enviorment (Flash Builder 4), the "size" member variable is defines as "uint".. Therefore, it only can handle files upto 4G. According to the doco, the latest versions of action script 3 should be "size" aNumber object.
Does anybody has seen that problem ? .. Is there a way to actualize the fileReference class ? ..
Marco
Please submit this enhancement into the bug tracking system
for the actionscript compiler:
http://bugs.adobe.com/asc/
Similar Messages
-
Previewing an image before uploading it using the FileReference class
Previewing an image before uploading it using the FileReference class in flash player 3 not in SDK4
Previewing an image before uploading it using the FileReference class in flash player 3 not in SDK4
-
Previewing an image before uploading it using the FileReference class in flex 3
Previewing an image before uploading it using the FileReference class in flex 3 ?
hai,
when this code is used in my application ,i got the name of image and new frame is added each time .But image is not displayed.....
The code starts like this
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init()" backgroundColor="white" width="100%" height="100%">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.messaging.Channel;
import mx.messaging.ChannelSet;
import mx.messaging.channels.AMFChannel;
import mx.rpc.events.ResultEvent;
import mx.controls.Image;
import spark.events.IndexChangeEvent;
import mx.managers.DragManager;
<mx:DataGridColumn headerText="Dimension Value" width="10" dataField="dimensionValue"/>
<mx:DataGridColumn headerText="Unit Nmae" width="10" dataField="dimensionUnitName"/>
</mx:columns>
</mx:DataGrid>
<mx:Spacer width="2%"/>
</mx:HDividedBox>
</mx:VBox>
<mx:Spacer height="0"/>
<mx:VBox width="100%">
<s:HGroup height="90" top="0" left="0" right="0" verticalAlign="justify" gap="10" paddingLeft="5" paddingRight="5" paddingTop="5" paddingBottom="5">
<s:Button id="btn_loader" top="5" bottom="24" width="100" label="load" click="loadImages()"/>
<s:Group width="100%">
<s:Group name="cl" top="0" left="0" bottom="0" width="20" mouseOver="//scroll_on(event)" mouseOut="//scroll_off(event)">
<s:BitmapImage source="@Embed('../assets/left.jpg')" top="0" left="0" bottom="0" right="0" fillMode="scale"/>
</s:Group>
<s:List id="imgList" skinClass="skins.ListSkin" top="-3" left="27" right="28" bottom="10"
dataProvider="{ImageCollection}" itemRenderer="Image_Render">
<s:layout>
<s:HorizontalLayout gap="0"/>
</s:layout>
</s:List>
<s:Group name="cr" top="0" right="0" bottom="0" width="20" mouseOver="//scroll_on(event)" mouseOut="//scroll_off(event)">
<s:BitmapImage source="@Embed('../assets/right.jpg')" top="-1" left="0" bottom="0" right="0" fillMode="scale"/>
</s:Group>
</s:Group>
</s:HGroup>
<s:SkinnableContainer id="dropCanvas" top="100" left="5" right="5" bottom="5" backgroundAlpha="1.0" alpha="1.0"
dragEnter="dropCanvas_dragEnterHandler(event)"
dragDrop="dropCanvas_dragDropHandler(event)" contentBackgroundColor="#914E4E" backgroundColor="#F7F7F7">
</s:SkinnableContainer>
</mx:VBox>
<mx:Spacer height="5"/>
</mx:VDividedBox>
</mx:Panel>
</mx:Canvas> -
Uploading bitmapData using FileReference class ?
Hi gurus ;)
Question nr 1.
Is it possibly to upload bitmapData to server using
FileReference class ? How should i approach this issue, is there
any ready classes available for this purpose. I'm generating
bitmaps inside my Flash/Flex App and need to store them under users
profile in server.
Question nr 2.
Can i upload files from remote server to another using
FileReference class
e.g Somehow like :
uploadURL = new URLRequest();
uploadURL.url = "
http://www.[yourDomain
fileURL.url = "
http://www.myLocation.com/myfile.JPG";
file = new FileReference(fileURL.url);
file.upload(uploadURL);
This is just an idea, sure not working ;)
Any ideas are helpful
Thx
iquaaaniI did a small application that uploads a file to the server
every hour. If the server response that a login is required to
upload the file, it goes to a login page to do the login and
retried to upload the file.
I got the server response in order to know if the file did
upload correctly or not (I have to send more form data than just
the file). I didn't try the mime type since it's not relevant for
my application and usualy this information is not very trust worthy
anyways.
I'm not sure what you mean with exceptions, if you are
referring to HTTP errors, I think there is an event for that, but I
used the IOError event for this, and it seems to work good
also. -
Using the fileReference class to upload image
I've been using the loadVars to upload text and pass
variables to php and onto the server. I've begun using the Flash
Filereference class so an image can be uploaded directly from a
Flash movie, not involving an html form. But within the
Filereference script I can't figure out how to pass a variable to
php as I did using loadVars method. I've tried a number of hit-miss
ways but they've all been misses.
Right now the path to save an image file is "hard-wired" into
the php script. This is the var that I want to pass.
thanks
The script is here if you need to take a peek:Someone else asked about this recently. I think the answer
you're after is here:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1317799
That's for POST data.
If you want to send additional GET data you could just append
it to the url. -
How can I load and save text using FileReference class
Let me start by saying I have no intention of using php and I can't wait until flash cs5 comes out with its new read/write capabilities
I want to load and save XML files (stored on my local hard-drive) in AS3.
I am using the FileReference class.
Firstly I have noticed that when using FileReference.save if you replace an existing file instead of writing over the file data is appended to the end of the file. Can I make it so the file is overwritten (as it should be) or make it impossible for the user to save in such a situation.
Secondly I want to load in text from an external file using FileReference.load I know that somehow you use FileReference.browse first to get it to work but I want to know exactly how to do it.
I have looked for a tutorial about loading text in this manner and have not found one.
Any help would be much appreciated especially if you could point me in the direction of a relevant tutorial
Thanksthe filereference class is for downloading and uploading files.
if you want to load xml, use the xml class.
and, if you want to write to an xml file and don't want to use server-side code, wait. -
Hey there,
After several days of banging my head against my desk trying to figure out what my application is doing wrong, I think I stumbled across a problem that either I'm not handling correctly in my code or that is a bug in the Flash Player plugin for Firefox on the Mac (and on Linux).
Here are my specs:
MacBook Pro with Snow Leopard 10.6.3
Firefox 3.6.3 w/ Flash Plugin 10.0.45.2
Safari 4.0.5 w/ Flash Plugin 10.0.45.2
FlashBuilder 4.0 (272416)
Flex 3.5 SDK
I can't post the code I've been working on as it's for a work project; however, I found something on Adobe's site that manifests this problem:
http://www.adobe.com/devnet/flash/quickstart/filereference_class_as3/
If you open up this page in Firefox 3.6 on the Mac, you may notice that the crop box doesn't work properly (or at least I noticed this behavior). What I would see is that the crop box would immediately fill to the lower right hand corner.
Open up the same link in Safari and it works properly.
The following is what I've noticed in my debugging efforts on my own application:
After completing a FileReference.load call, the Flash application appears to lose focus (perhaps to the operating system?)
Moving the cursor (both in my case and I think in the example on the site) results in getting undefined (and astronomical) values back when you poll for the mouse cursor's position.
Clicking outside of Firefox and clicking back in seems to resolve this. It seems like leaving the window and returning solves the problem.
To provide another example of this behavior, I've altered some code that does a similar function to the example on Adobe's site to produce some statistics about where the mouse cursor is:
The code example:
http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the- filereference-class-in-flash-player-10/#more-766
My code (my changes are bolded):
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/08/25/previewing-an-image-before-uploading-it-using-the- filereference-class-in-flash-player-10/ -->
<s:Application name="FileReference_load_test"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
xmlns:net="flash.net.*" xmlns:mx1="library://ns.adobe.com/flex/mx"
creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.utils.ObjectUtil;
[Bindable]
private var appX:Number;
[Bindable]
private var appY:Number;
private function init():void {
addEventListener(MouseEvent.MOUSE_MOVE, handleMove);
private function handleMove(event:MouseEvent):void {
appX = event.localX;
appY = event.localY;
private function btn_click(evt:MouseEvent):void {
var arr:Array = [];
arr.push(new FileFilter("Images", ".gif;*.jpeg;*.jpg;*.png"));
fileReference.browse(arr);
private function fileReference_select(evt:Event):void {
fileReference.load();
private function fileReference_complete(evt:Event):void {
img.source = fileReference.data;
Alert.show(ObjectUtil.toString(fileReference));
]]>
</fx:Script>
<fx:Declarations>
<net:FileReference id="fileReference"
select="fileReference_select(event);"
complete="fileReference_complete(event);" />
</fx:Declarations>
<s:Panel id="panel"
horizontalCenter="0"
verticalCenter="0"
width="500">
<s:layout>
<s:VerticalLayout />
</s:layout>
<mx1:Image id="img"
verticalCenter="0"
horizontalCenter="0"
maxWidth="200"
maxHeight="200" />
<mx1:ControlBar>
<s:Button id="btn"
label="Browse and preview..."
click="btn_click(event);" />
<s:Button label="Upload..."
enabled="false" />
<s:Label text="MouseX:" />
<mx1:Text text="{appX}" />
<s:Label text="MouseY:" />
<mx1:Text text="{appY}" />
</mx1:ControlBar>
</s:Panel>
</s:Application>
If you compile and run this application in Firefox, you should see that the X and Y values for the mouse stop updating after the file is loaded. On Safari they continue to update.
I couldn't find any reference to this problem searching on Google (perhaps not the right keywords?).
Anyone have any input on this issue? Any help is appreciatedUpdates:
I've opened a bug with Adobe regarding this issue:
http://bugs.adobe.com/jira/browse/FP-4362
Also, the Cancel operation on a FileReference causes the same issue to happen as does loading. I really think it's an operating system focus issue.
UPDATE:
Looks like this has already been tracked and is scheduled to be fixed:
https://bugs.adobe.com/jira/browse/FP-2785 -
FileReference.save() change the default save location
I am creating an application in flex that downloads a file from the server and saves it to a default location on the server.
such as USER_HOME/CONFIG/FILES folder.
I've figured that the FlexReference triggers the OS, which open the downloads folder by default in the save dialog. [i am not concrete of this ]
but i want to make this default save dialog to open this folder: USER_HOME/CONFIG/FILES
Is it possible using FileReference Class?
i have been trying to find a way to do this from the past one week.
can anyone help me?
Thanks
garyAnother way to do it.
Home Folder - Move -
Hi All,
Basically I am developing my own Adobe Air FTP client application (Flex builder 4.6). I have have successfully managed to get the user to select one or more files from their local machine to send via FTP. The file(s) are then added to an arrayCollection which populates a data grid.
I then have an upload button that when pressed I need to loop through each file that has previously been selected and pick up the file name, size and data stored within the file. I know I can use the FileReference class and the load() method to load the file and access the data via the .data method but the data variable is always null meaning i am obviously not using the load() method in the relevant place in the code.
Can anyone help me get around this probblem please??
Below are my snippets of code that I think you will need:
When the Browse button is selected it fires the selectHandler function below to add files to the data grid:
private function selectHandler(event:Event):void {
fileList = fileReferenceList.fileList;
for (var i:Number=0; i<fileList.length; i++) {
var file:FileReference = FileReference(fileList[i]);
arrayCollection.addItem({name:file.name, size:file.size, object:file})
uploadTest.enabled = true;
When i click the upload button i need to loop through all of the selected files which I am doing using a for each loop:
private function uploadFile(event:MouseEvent):void {
//Loops through each array element
for each( var obj:Object in arrayCollection ) {
//Need to get file details in here - PLEASE HELP??
Thanks
PaulUhm, as you "check the folder daily", you'll have one or the other junk mail popping up in the preview frame anyway, right?
Well, as soon as you decided you want to delete all junk mail, you can do so without seeing any of them anymore:
With any of the other mailboxes selected and showing, right-click on any of the mailboxes (can be Inbox, Flagged, Sent, Junk, Trash), then click Erase Junk Mail and answer the following dialog with Erase.
The junk mails will be erased without you - or anyone looking over your shoulder - seeing even only one anymore. -
Getting the response from a FileReference upload
This question is about the "upload" method of the
FileReference class.
Is there any way to read the HTTP response after a file
upload is complete? For example, a user uploads an file to a
server. The server saves the file and assigns it an ID. The server
then writes the ID to the HTTP response. How does the client read
that response?inlineblue wrote:
This was kicked around a while back in the Flexcoders list.
Everyone agrees this would be very useful, but not currently
available. Sigh.
Flexcoders said what? (Am I missing something? Ahh - the date of the original post...)
fileReference.addEventListener(DataEvent.UPLOAD_COMPLETE_DATA, uploadComplete);
private function uploadComplete(event:DataEvent):void {
trace(event.data);
getWriter() or getOutputStream() on the servlet response to send "stuff" back... -
Hello!
I am having either thought constipation or lack of knowledge
or both. Or maybe I want too much.
My application allows user to select an MP3 file from his
hard drive and upload it to the server utilizing FileReference
class -- they browse, select and upload. Everything works fine
except I would like to give them an opportunity to listen to MP3
after they select the file but BEFORE they attempt uploading it. Of
course I could just let them upload the thing and then stream it
back but I don't like an easy life.
Naturally, loadSound("blah.mp3") doesn't work because I
cannot know path to their file (or can I?). In any case I could not
find a way to get the path to the selected file, which is fair from
the security standpoint.
I hoped that the file accessed through FileReference would be
somehow translated as an object into datatype SOUND (FileReference
obviously knows that it deals with MP3 – not the MIME though
– and it would be nice to write my_sound:Sound = new Sound();
my_sound = my_selected_file; and get over with the issue) -- in
which case I would just start playing it. My high expectations did
not come true. I guess the shortest rendition of my question is: Is
there any way to convert selected MP3 into sound object, which I
can manipulate?
I hope I am clear...
Thank you very much!> you can't write to a local file (except an so) using a swf in a browser.
An SWF can write to a local file using a FileReference. See:
http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-playe r-10/ -
FileReference doesn't work with PHP Globals
<help>,
Ok so this is my problem. I have a flash movie that allows
users to uploads two images to a server. What I'm trying to do is
have the uploaded images go directly to their user's directory. I
need the upload.php file to figure out which person is uploading an
image. The php page that handles the file uploads will not read in
any global variables (i.e. POST, GET, SESSION, COOKIE). Also
FileReference.upload() doesn't allow you to send any GET / POST
vars along with it (as far as I have tested and read about). I've
been working on this for four days now and have concluded it's
something to do with the Flash FileReference calling the php page.
I believe for some reason when FileReference calls the php page the
web server doesn't like/allow/understand how the page is called so
it denies any global var requests. I know its flash because it
works if I use an html front end with the same php uploader page.
So the goal for you 'out of the box' thinkers is to get one
single darn global variable pulled into the php upload page. The
ONLY way I can think of doing this is when every time a user
creates an account and their folder is created, it copies the php
upload file their directory. Then in flash when a user needs to
upload its calls the upload file in each persons upload directory.
Needless to say I do not want to do it this way but I'm running out
of ideas.
P.S. someone has suggested uploading the images to a temp
file name and then immediatly move the image to the users folder
but I I'm tentive to do it that way since you could get two people
uploading at the same time and one person would get the second
person's image and the second person would get an error.
<!--- actionscript code
this._fileRef.upload("upload.php"); <---- works
this._fileRef.upload("upload.php?user_id=4"); <---- does
not work
//-->
<?php
session_start();
$user_id = $_SESSION['user_id']; // Does not work
$user_id = $_COOKIE['user_id']; // Does not work
$user_id = $_GET['user_id']; // Does not work
$user_id = $_POST['user_id']; // Can't do with FileReference
class
?>
</help>This may help. You can pass some URL encoded data with the
FileReference
upload method.
file_fr.upload("upload.php?testvar=Hello World " +Date());
Then this is a demo on how you can see that data, which you
would need to
rework to use to set the path.
<?php
if ($_FILES['Filedata']['name']) {
$uploadDir = "images/";
$uploadFile = $uploadDir .
basename($_FILES['Filedata']['name']);
move_uploaded_file($_FILES['Filedata']['tmp_name'],
$uploadFile);
$filename = "output.txt";
$fp = fopen( $filename,"w+");
fwrite ( $fp, "Test" );
fwrite ( $fp, $_REQUEST['testvar'] );
fclose( $fp );
?>
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"Webmaster Pete" <[email protected]> wrote
in message
news:[email protected]...
> <help>,
>
> Ok so this is my problem. I have a flash movie that
allows users to
> uploads
> two images to a server. What I'm trying to do is have
the uploaded images
> go
> directly to their user's directory. I need the
upload.php file to figure
> out
> which person is uploading an image. The php page that
handles the file
> uploads
> will not read in any global variables (i.e. POST, GET,
SESSION, COOKIE).
> Also
> FileReference.upload() doesn't allow you to send any GET
/ POST vars
> along
> with it (as far as I have tested and read about). I've
been working on
> this for
> four days now and have concluded it's something to do
with the Flash
> FileReference calling the php page. I believe for some
reason when
> FileReference calls the php page the web server doesn't
> like/allow/understand
> how the page is called so it denies any global var
requests. I know its
> flash
> because it works if I use an html front end with the
same php uploader
> page.
>
> So the goal for you 'out of the box' thinkers is to get
one single darn
> global variable pulled into the php upload page. The
ONLY way I can think
> of
> doing this is when every time a user creates an account
and their folder
> is
> created, it copies the php upload file their directory.
Then in flash when
> a
> user needs to upload its calls the upload file in each
persons upload
> directory. Needless to say I do not want to do it this
way but I'm running
> out
> of ideas.
>
> P.S. someone has suggested uploading the images to a
temp file name and
> then
> immediatly move the image to the users folder but I I'm
tentive to do it
> that
> way since you could get two people uploading at the same
time and one
> person
> would get the second person's image and the second
person would get an
> error.
>
> <!--- actionscript code
> this._fileRef.upload("upload.php"); <---- works
> this._fileRef.upload("upload.php?user_id=4"); <----
does not work
> //-->
>
> <?php
> session_start();
> $user_id = $_SESSION['user_id']; // Does not work
> $user_id = $_COOKIE['user_id']; // Does not work
> $user_id = $_GET['user_id']; // Does not work
> $user_id = $_POST['user_id']; // Can't do with
FileReference
> class
> ?>
>
> </help>
> -
Adobe air on iOS - FileReference Download Error
I guys,
when I use the Download method of the FileReference class, everything works fine on Desktop and Android, but I get an error on iOS.
This is the code:
var req = new URLRequest(url);
var localRef:FileReference = new FileReference();
localRef.download(req);
On iOS I'm getting an Alert:
Download Error
File downloads not supported.
I already tried to NavigateToUrl() and it asks save the file in Dropbox or another App.
How can I fix this error?
Thanks!What are you intending to do with the downloaded file? Will it be used solely by the app, or you attempting to download some othe media (photo, video, music, etc.) to be referenced outside the app.
If you want to do the former I think I can help...
The later, I am not sure how to, or if you can, do. -
FileReference.save() file type filter options?
OK, I’m loving the new access to the FileReference class to load and save XML to the user’s local drive without sending out for pizza first, but I have one minor complaint:
FileReference.browse() lets me filter the read choices to xml files only, so I can strongly encourage the user to only open files with the proper extension, however, FileReference.save() doesn’t seem to support similar filtering, so the user can save data with any old extension, making it easy for them to accidently hide the saved file from the open dialog box. Am I missing something or is there a user friendly way to match read/write file types.I don't believe you can get that functionality using FileReference in Flash Player.
-
How do I retrieve the data bytearray from a FileReference once it has been downloaded? Everywhere I look online about this simply states that in a web browser this data is not accessible because it's a security issue, but in Air this is not an issue. None of the places I've found that though have then proceeded to explain how to retrieve the FileReference.data information.
Here's my workflow:
--User selects attachment to download
--FileReference runs it's download() function and prompts with a native air save dialog box
--FileReference downloads the file and executes it's Event.COMPLETE listener, which calls my downloadComplete(Event) function
--At this point inside the downloadComplete function I cannot grab the fileReference's data parameter because it's null, and the event.target.data value is also null
What I'm trying to do with the bytearray data is then use FileStream to write a temp file out, then use the File class to execute the file with it's default application after the user clicks 'Open'. Does anyone have any idea about how to actually grab the bytearray information though?scratch all that, I figured out that the File class has the same functionality that I needed as the FileReference class, switched types and I was good to go.
Maybe you are looking for
-
Asset accounting with parallel ledgers.
Hi SAP gurus, My client has a scenario where assets have different accounting principles, as example, buying an equipment is considered as investment in one perspective and as expense on another. To do that we have created two depreciation areas (01
-
How can i modify or delete desktop files and folders in Mac OS 10.6.8 ?
i have Macbook pro running on Mac OS X, Snow Leopard ver. 10.6.8 . I am not able to delete rename and modify my desktop folder and files. even through the admin account and all previleges i cant move them to Thrash. as i try to delete them it asks fo
-
HT201304 I forgot my restriction pass code , how do I retrieve it or change it?
I have forgotten my restrictions pass code. How do I retrieve my pass code or how can I change it. Thanks
-
How do I return Font Book back to it's install condition?
I accidently dropped a couple of thousand fonts into Font Book. (Big clumsy hands, me) What is the best way to get Font Book back to it's install default condition? I will get TimeMachine up and running - next time I won't have this problem.
-
URGENT: What else is necessary for me and why?
Hi All! I am desiging a socket based data transmission system, and our messages, Connection Logs, Application Configuration Data will be stored in xml format. I have also designed dtd for them. I NEED TO KNOW WHY AND WHICH OF (XSL, XSLT, XPATH, DOM,