Hi Piotr,

It looks like IFileModel should have a

set fileContent(content:BinaryData):void

Then, FileModelWithParams would set the correct param in the FormData and 
FileModel would simply set blob.

IFileModel.blob should be read only.

That way, you can still use the rest of the beads the same way, only changing 
the model. How does that sound?

From: Piotr Zarzycki<mailto:[email protected]>
Sent: Sunday, July 14, 2019 10:21 PM
To: [email protected]<mailto:[email protected]>
Subject: Re: Uploading files with parameters

This is great idea Yishay, but I see one scenario where having in model
blop property as FormData type will fail. If I would like to Load and
Upload later file blop has to be BinaryData. - This is actually what we are
trying to do. We need to use FileLoaderAndUploader.

However if I create that new model with additional field called params:
FormData  it could use in following way with code [1]

1) File is being browsed and assigned to "file" property in IFileModel
2) FileLoaderAndUploader - loads it cause "blop" property is empty
3) "blop" property is being filled after loading and it's BinaryData
4) Everything is happened in following line [2] when at the end when we
would like to upload stuff. Here we could use params (FormData), put File
in params and send. I don't know what should
be the name of the param actually for file, but maybe there is no official
default name. Here is some examples [3]

[1] https://paste.apache.org/8mxx3
[2]
https://github.com/apache/royale-asjs/blob/51636852d1d791703cb74b011741fb1f003d5863/frameworks/projects/Network/src/main/royale/org/apache/royale/net/URLStream.as#L136
[3]
https://developer.mozilla.org/en-US/docs/Web/API/FormData/Using_FormData_Objects

Thanks,
Piotr

niedz., 14 lip 2019 o 14:10 Yishay Weiss <[email protected]>
napisał(a):

> It could be enough to create a new model FileModelWithParams implements
> IFileModel which has blob() return FormData in JS. I don’t think you need
> FileUploaderWithParams because the present one reads the blob from the
> model anyway.
>
>
>
> ________________________________
> From: Piotr Zarzycki <[email protected]>
> Sent: Sunday, July 14, 2019 2:54:18 PM
> To: [email protected]
> Subject: Re: Uploading files with parameters
>
> I just looked into  FileModel and IFileModel. FileUploader using FileModel,
> but this is because IFileModel doesn't contains "blop" property - I think
> IFileModel should contains such.
>
> It is definitely worth to make FileUploader using IFileModel.
>
> Next I could create bead FileUploaderWithParams extends FileUploader which
> could use new interface IFileModelWithParams extends IFileModel.
>
> Thoughts ?
>
> Thanks,
> Piotr
>
> niedz., 14 lip 2019 o 13:41 Piotr Zarzycki <[email protected]>
> napisał(a):
>
> > Hi Yishay,
> >
> > Some comments inline.
> >
> > [1]  https://paste.apache.org/rk1ro
> >
> > sob., 13 lip 2019 o 14:06 Yishay Weiss <[email protected]>
> > napisał(a):
> >
> >> Hi Piotr,
> >>
> >>
> >>
> >> The beads [1] you mentioned are supposed to implement FileReference
> >> methods, that’s why I was asking about the flash way of doing it.
> >>
> >>
> >>
> > *We are doing it in following way [1].*
> >
> >
> >>
> >> Maybe this example [3] helps.
> >>
> >>
> >>
> > *Yes this example was very helpful and we are doing upload in exactly the
> > same way. *
> >
> >
> >>
> >> As I understand the SO answers [2], they’re suggesting to either send
> the
> >> params on the url or in a FormData.
> >>
> >>
> >>
> >> For the former solution you can add <FileUploader id=”myUploader/> bead
> >> to the file proxy and then on blobChangedHandler() you can make a call
> like:
> >>
> >>
> >>
> >> myUploader.upload(url?param1=1&param2=2)
> >>
> >>
> >>
> > *As you can see in my link [1] we are doing that in a way as you are
> > suggesting in Flex. In Royale I would like to avoid completely such
> things
> > like concatenating string in order to build url. That's way I have
> started
> > this thread to make sure that I'm not missing some better way than this.
> It
> > looks like I need to implement it. Thanks for confirmation actually.*
> >
> >
> >>
> >> If you want the latter solution you can create a new IFileModel bead
> with
> >> params that would implement FormData on the JS side.
> >>
> >>
> >>
> >> It could be that FileUploader needs to be refacotred to read and
> >> IFileModel instead of an IModel, and that blob() should be part of the
> >> interface and return an Object.
> >>
> >>
> >>
> > *Once I jump into implementation I will take into account your
> > suggestions.*
> >
> >
> >>
> >> Hope you understand when you look at the code, otherwise ask.
> >>
> >>
> >>
> >> Thanks.
> >>
> >>
> >>
> >> [1]
> >>
> https://github.com/apache/royale-asjs/tree/develop/frameworks/projects/Network/src/main/royale/org/apache/royale/file/beads
> >>
> >> [2] https://stackoverflow.com/questions/15218292/xhr-sendfile-params
> >>
> >> [3] https://github.com/yishayw/Examples/blob/FileProxy/Examples.mxml
> >>
> >>
> >>
> >> ________________________________
> >> From: Piotr Zarzycki <[email protected]>
> >> Sent: Friday, July 12, 2019 8:50:53 PM
> >> To: [email protected]
> >> Subject: Re: Uploading files with parameters
> >>
> >> Hi Yishay,
> >>
> >> I'm trying to achieve exactly what is in the link from SOF.
> >>
> >> Thanks,
> >> Piotr
> >>
> >> On Fri, Jul 12, 2019, 7:35 PM Yishay Weiss <[email protected]>
> >> wrote:
> >>
> >> > Can you show a flash snippet of what you’re trying to achieve? Would
> you
> >> > be using FileReference in flash?
> >> >
> >> >
> >> >
> >> > ________________________________
> >> > From: Piotr Zarzycki <[email protected]>
> >> > Sent: Friday, July 12, 2019 4:02:13 PM
> >> > To: [email protected]
> >> > Subject: Re: Uploading files with parameters
> >> >
> >> > Hi Harbs,
> >> >
> >> > I mean something like here [1] - I'm not sure if it answers to your
> >> > question.
> >> >
> >> > [1] https://stackoverflow.com/questions/15218292/xhr-sendfile-params
> >> >
> >> > Thanks,
> >> > Piotr
> >> >
> >> > pt., 12 lip 2019 o 14:58 Harbs <[email protected]> napisał(a):
> >> >
> >> > > Do you mean multipart or something else?
> >> > >
> >> > > > On Jul 12, 2019, at 3:44 PM, Piotr Zarzycki <
> >> [email protected]
> >> > >
> >> > > wrote:
> >> > > >
> >> > > > Hey Guys,
> >> > > >
> >> > > > We are progressing with port Flex app to Royale. One of the
> feature
> >> in
> >> > > that
> >> > > > app is uploading File to server sigh along with couple of
> additional
> >> > > > parameters. I see that uploading is possible trough several beads
> >> > > available
> >> > > > here [1].
> >> > > >
> >> > > > Unfortunately non of them provides nice options to add as part of
> >> the
> >> > > > upload additional parameters.
> >> > > >
> >> > > > I'm going to implement FileUploaderWithParams bead where ability
> of
> >> > > adding
> >> > > > additional params as object will be handled.
> >> > > >
> >> > > > Is there anything that I'm missing here ?
> >> > > >
> >> > > > [1]
> >> > > >
> >> > >
> >> >
> >>
> https://github.com/apache/royale-asjs/tree/develop/frameworks/projects/Network/src/main/royale/org/apache/royale/file/beads
> >> > > >
> >> > > >
> >> > > > Thanks,
> >> > > > --
> >> > > >
> >> > > > Piotr Zarzycki
> >> > > >
> >> > > > Patreon: *https://www.patreon.com/piotrzarzycki
> >> > > > <https://www.patreon.com/piotrzarzycki>*
> >> > >
> >> > >
> >> >
> >> > --
> >> >
> >> > Piotr Zarzycki
> >> >
> >> > Patreon: *https://www.patreon.com/piotrzarzycki
> >> > <https://www.patreon.com/piotrzarzycki>*
> >> >
> >>
> >
> >
> > --
> >
> > Piotr Zarzycki
> >
> > Patreon: *https://www.patreon.com/piotrzarzycki
> > <https://www.patreon.com/piotrzarzycki>*
> >
>
>
> --
>
> Piotr Zarzycki
>
> Patreon: *https://www.patreon.com/piotrzarzycki
> <https://www.patreon.com/piotrzarzycki>*
>


--

Piotr Zarzycki

Patreon: *https://www.patreon.com/piotrzarzycki
<https://www.patreon.com/piotrzarzycki>*

Reply via email to