You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@royale.apache.org by Hugo Ferreira <hf...@gmail.com> on 2022/12/07 00:32:11 UTC

Alternative for browseForOpenMultiple

Hi,

In Flex I was able to select and upload multiple file at once.
Example:

var filter:FileFilter = new FileFilter("PDF", "*.pdf");
var file:File = new File();
file.addEventListener(FileListEvent.SELECT_MULTIPLE, handleFilesSelected);
file.browseForOpenMultiple("Select files: ", [filter]);

Since there is no direct browseForOpenMultiple in Apache Royale, there is
another way or there is currently no native alternative ?

Thanks,
Hugo.

Re: Alternative for browseForOpenMultiple

Posted by Hugo Ferreira <hf...@gmail.com>.
Hi,

In the last few days I built a bead MultipleFiles and ended up changing a
lot in FileReference.
The thing is that FileReference was designed in mind for a single file and
a lot of changes would be required.

This is a long task of rewriting a Flex application to Royale and there is
a single place that requires multiple files upload, so, I decide to
implement it directly with JS and not change the Royale Framework, avoiding
this complexity.

Of course, if in future this becomes more required (even for another user),
I can dive and implement it (perhave a browseForMultiple method instead of
a bead on this particular scenario and not change the original method).

Here my JS code only for this specific and singular use case:

var input:Element = document.createElement("input");
input.setAttribute("type", "file");
input.setAttribute("accept", "application/pdf");
input.setAttribute("multiple", true);
input.addEventListener("change", function():void
{
for (var i:int = 0; i < input["files"].length; i++)
{
var reader:FileReader = new FileReader();
reader["fileName"] = input["files"][i].name;
reader.addEventListener("load", function(e:Event):void
{
var fileName = e.target.fileName;
var fileData = btoa(e.target.result);

//do what necessary with file name and file data now with AS
});
reader.readAsBinaryString(input["files"][i]);
}
});
input.click();
}

Yishay Weiss <yi...@hotmail.com> escreveu no dia terça, 13/12/2022
à(s) 08:00:

> I had a look at Royale’s mx FileReference emulation to remember the
> implementation. Doesn’t look like there’s an option for multi select. I
> think it would require adding a bead that extends
> org.apache.royale.file.beads.FileBrowser and adds the multiple attribute to
> the delegate which is an input of type file. That’s for mult-selection. In
> as far as the upload operation itself I have not followed the
> implementation to see what that entails.
>
> Maybe others who have done work on this can comment.
>
> From: Hugo Ferreira<ma...@gmail.com>
> Sent: Wednesday, December 7, 2022 2:31 AM
> To: Apache Royale Development<ma...@royale.apache.org>
> Subject: Alternative for browseForOpenMultiple
>
> Hi,
>
> In Flex I was able to select and upload multiple file at once.
> Example:
>
> var filter:FileFilter = new FileFilter("PDF", "*.pdf");
> var file:File = new File();
> file.addEventListener(FileListEvent.SELECT_MULTIPLE, handleFilesSelected);
> file.browseForOpenMultiple("Select files: ", [filter]);
>
> Since there is no direct browseForOpenMultiple in Apache Royale, there is
> another way or there is currently no native alternative ?
>
> Thanks,
> Hugo.
>
>

RE: Alternative for browseForOpenMultiple

Posted by Yishay Weiss <yi...@hotmail.com>.
I had a look at Royale’s mx FileReference emulation to remember the implementation. Doesn’t look like there’s an option for multi select. I think it would require adding a bead that extends org.apache.royale.file.beads.FileBrowser and adds the multiple attribute to the delegate which is an input of type file. That’s for mult-selection. In as far as the upload operation itself I have not followed the implementation to see what that entails.

Maybe others who have done work on this can comment.

From: Hugo Ferreira<ma...@gmail.com>
Sent: Wednesday, December 7, 2022 2:31 AM
To: Apache Royale Development<ma...@royale.apache.org>
Subject: Alternative for browseForOpenMultiple

Hi,

In Flex I was able to select and upload multiple file at once.
Example:

var filter:FileFilter = new FileFilter("PDF", "*.pdf");
var file:File = new File();
file.addEventListener(FileListEvent.SELECT_MULTIPLE, handleFilesSelected);
file.browseForOpenMultiple("Select files: ", [filter]);

Since there is no direct browseForOpenMultiple in Apache Royale, there is
another way or there is currently no native alternative ?

Thanks,
Hugo.