Customizing MFU

13 views
Skip to first unread message

abhi

unread,
Sep 8, 2010, 5:20:18 AM9/8/10
to multiplefileuploader
Hi All,

I am evaluating mfu for use in our web application. I have some doubts
to clarify. I am using a local folder to save the file.

1. How can I restrict mfu widget to just one entry? i.e, I want the
user to be able to upload only one file(no 'Attach another file
option')

2. The argument, "uploadFilePrefix" does not seem to be working. All
my files on the server are stored with the same name as the original.

3. Why is the upload starting when I select the file. How can a user
cancel an ongoing upload?

4. What event is fired when an error occurs. I don't want mfu to show
a red labeled text.

I also made some css changes to make the fake button look like a real
one. I will submit the patches as soon as possible.

Here is my code
var params = {
ajaxUploadUrl: "/php/upload.php",
uploadStatusURL : "/php/status.php",
uploadValuePrefix : kwargs['channel']+ "_"
};
var upload = new
multiplefileuploader.widget.MultipleFileUploader( params,
dojo.byId("uploadFileContainer") );

--
Abhi

florent valdelievre

unread,
Sep 8, 2010, 5:38:48 AM9/8/10
to multiplefi...@googlegroups.com
Hello abhi,

1) As the goal of this uploader is to propose to upload mutiple files, we did not develop anything to disable 'attach another file' link.
However, by adding display:none in the template, you will be able to get rid of that link.

2) uploadFilePrefix is not a filename prefix on your server. This logic has to be make server side.
uploadFilePrefix is the file prefix you want to put in the DOM once the file is uploaded like :
<input type="hidden" dojoattachpoint="uploadedFileID" id="uploadedFile_a759d9f599bac490ef4f719ad7b3fab0">

3) We cant cancel an ongoing upload in javascript. The only way to do it is to add a flash abstraction. As this uploader is full javascript, we dont have the possibility to cancel an upload.

4) OnError is fired when an error occurs ( http://github.com/samokk/multiplefileuploader/blob/master/src/multiplefileuploader/widget/MultipleFileUploader.js )

what do you mean by 'I also made some css changes to make the fake button look like a real one.' ?

Cheers

Florent


2010/9/8 abhi <ab...@littlewiki.in>

abhi

unread,
Sep 8, 2010, 6:25:31 AM9/8/10
to multiplefileuploader
On Sep 8, 2:38 pm, florent valdelievre <florentvaldelie...@gmail.com>
wrote:
> Hello abhi,
>
> 1) As the goal of this uploader is to propose to upload mutiple files, we
> did not develop anything to disable 'attach another file' link.
> However, by adding display:none in the template, you will be able to get rid
> of that link.
I will patch mfu to do it via JS and submit the patch here because I
needed both single and multiple modes.
>
> 2) uploadFilePrefix is not a filename prefix on your server. This logic has
> to be make server side.
> uploadFilePrefix is the file prefix you want to put in the DOM once the file
> is uploaded like :
> <input type="hidden" dojoattachpoint="uploadedFileID"
> id="uploadedFile_a759d9f599bac490ef4f719ad7b3fab0">
>
Got it.
> 3) We cant cancel an ongoing upload in javascript. The only way to do it is
> to add a flash abstraction. As this uploader is full javascript, we dont
> have the possibility to cancel an upload.
>
Ok
> 4) OnError is fired when an error occurs (http://github.com/samokk/multiplefileuploader/blob/master/src/multipl...)
>
What I also meant was the widget itself must not write it out in the
DOM(in bold red color) if the operation failed but instead just raise
an exception or call onError.
> what do you mean by 'I also made some css changes to make the fake button
> look like a real one.' ?
>
Apparently, the css was not making the fake button look like a button
in claro, so I changed the button styling a bit.

.claro .dijitFileInputButton,
.claro .dijitFileInputText {
-background-image: url("../../../dojo-release-1.5.0-src/dijit/themes/
claro/form/images/button_back_full.png");
-background-position: center top;
-background-repeat: repeat-x;
-background-color: #cde3f6;
+background-image: url("/dojoroot/dijit/themes/claro/form/images/
button.png");
+background-color: #E4F2FF;
border: 1px solid #799ab7;
padding:2px 12px 2px 12px;
-border-radius: 4px;
--moz-border-radius: 4px;
--webkit-border-radius: 4px;
-box-shadow:0px 1px 1px rgba(0,0,0,0.2);
--webkit-box-shadow:0px 1px 1px rgba(0,0,0,0.2);
--moz-box-shadow: 0px 1px 1px rgba(0,0,0,0.2);
+background-position:center top;
+background-repeat:repeat-x;
+border:1px solid #769DC0;
+padding:2px 4px 4px;
}
-
The fake div also needs a :hover to give the effect of a buttonHover.
I also noted that you are setting .claro in the css which may not be
optimal as it would affect the entire application's css. I also
changed the relative paths of the image files to /dojoroot/ as it is
more "relative" than ../../dojo... etc.

--
Abhi

Sami Dalouche

unread,
Sep 8, 2010, 8:23:12 AM9/8/10
to multiplefileuploader


On Sep 8, 6:25 am, abhi <a...@littlewiki.in> wrote:
> On Sep 8, 2:38 pm, florent valdelievre <florentvaldelie...@gmail.com>
> wrote:> Hello abhi,
>
> > 1) As the goal of this uploader is to propose to upload mutiple files, we
> > did not develop anything to disable 'attach another file' link.
> > However, by adding display:none in the template, you will be able to get rid
> > of that link.
>
> I will patch mfu to do it via JS and submit the patch here because I
> needed both single and multiple modes.
>
>

OK, great ! Please do not hesitate to post if you need help regarding
which sections of the code need to be changed.

>
>
>
> > 2) uploadFilePrefix is not a filename prefix on your server. This logic has
> > to be make server side.
> > uploadFilePrefix is the file prefix you want to put in the DOM once the file
> > is uploaded like :
> > <input type="hidden" dojoattachpoint="uploadedFileID"
> > id="uploadedFile_a759d9f599bac490ef4f719ad7b3fab0">
>
> Got it.

Yes, this is not really useful by itself, and we could even completly
delete this config parameter, as the only thing it does is influence
the client-server protocol...

> > 3) We cant cancel an ongoing upload in javascript. The only way to do it is
> > to add a flash abstraction. As this uploader is full javascript, we dont
> > have the possibility to cancel an upload.
>
> Ok
> > 4) OnError is fired when an error occurs (http://github.com/samokk/multiplefileuploader/blob/master/src/multipl...)
>
> What I also meant was the widget itself must not write it out in the
> DOM(in bold red color) if the operation failed but instead just raise
> an exception or call onError.

Yes, you're right ! There is currently no way to influence this
behavior. I added this idea to our backlog
http://github.com/samokk/multiplefileuploader/blob/master/TODO

BTW, some work is also needed concerning the other on* events. as we
lack some useful events, and the ones implemented do not get enough
information to do anything useful.

abhi

unread,
Sep 10, 2010, 12:34:41 PM9/10/10
to multiplefileuploader

On Sep 8, 5:23 pm, Sami Dalouche <sami.dalou...@gmail.com> wrote:
>
> OK, great ! Please do not hesitate to post if you need help regarding
> which sections of the code need to be changed.
>
This is what I did:
I added an extra class variable, uploadMultiple and in line 127:
http://bit.ly/d3snjb
this.uploadUnitContainer = new
multiplefileuploader.widget.UploadUnitContainer(params,
this.fileUploadContainer , this.uploadActionsContainer);
if (!this.uploadMultiple){

dijit.byId(this.uploadUnitContainer._uploadActions.id).destroy()
}

It's more of a hack and I think the proper way would be in
uploadActions.js
>
>
>
> > > 3) We cant cancel an ongoing upload in javascript. The only way to do it is
> > > to add a flash abstraction. As this uploader is full javascript, we dont
> > > have the possibility to cancel an upload.
>
I see that you are using a dojo.io.iframe for the real upload. Is it
not possible to have a deferred.cancel() on that to cancel an upload ?
I have never used io.iframe but is it possible ?

Sami Dalouche

unread,
Sep 12, 2010, 9:43:34 AM9/12/10
to multiplefi...@googlegroups.com
Hi,


On Fri, Sep 10, 2010 at 12:34 PM, abhi <ab...@littlewiki.in> wrote:
>
> On Sep 8, 5:23 pm, Sami Dalouche <sami.dalou...@gmail.com> wrote:
>>
>> OK, great ! Please do not hesitate to post if you need help regarding
>> which sections of the code need to be changed.
>>
> This is what I did:
> I added an extra class variable, uploadMultiple and in line 127:
> http://bit.ly/d3snjb
>      this.uploadUnitContainer = new
> multiplefileuploader.widget.UploadUnitContainer(params,
> this.fileUploadContainer , this.uploadActionsContainer);
>      if (!this.uploadMultiple){
>
> dijit.byId(this.uploadUnitContainer._uploadActions.id).destroy()
>      }
>
> It's more of a hack and I think the proper way would be in
> uploadActions.js
>>
>>

Both MultipleFileUploader and UploadActions are widgets that we try to
keep free of business logic.
The responsibility of these components is to manage the display /
templates and bind the events to the right
business logic.

So, my guess would be that :
- MultipleFileUploader could have an additional variable that stores
the maximum number of upload units
that we want to allow. (I guess a number of more flexible than a
boolean indicating whether we want single/multiple mode)
- UploadUnitContainer.supportsAdditionalUploadUnits() could be created
to check the max-number-of-units
and inform whether it is allowed to create a new upload unit. This
method could be called in UploadActions to
hide the button when no more additionalUploadUnits can be created.
- UploadUnitContainer.createUploadUnit() could be a good place to
check the max-number-of-units logic
(and throw an exception if max has been reached ?)
before creating a new upload unit. (not strictly necessary if the
button is not displayed, but this would make the logic
more defensive.

What do you think ?


>>
>> > > 3) We cant cancel an ongoing upload in javascript. The only way to do it is
>> > > to add a flash abstraction. As this uploader is full javascript, we dont
>> > > have the possibility to cancel an upload.
>>
> I see that you are using a dojo.io.iframe for the real upload. Is it
> not possible to have a deferred.cancel() on that to cancel an upload ?
> I have never used io.iframe but is it possible ?
>> > Ok
>> > > 4) OnError is fired when an error occurs (http://github.com/samokk/multiplefileuploader/blob/master/src/multipl...)
>>
>> > What I also meant was the widget itself must not write it out in the
>> > DOM(in bold red color) if the operation failed but instead just raise
>> > an exception or call onError.
>>
>

From what I remember, It seemed like cancelling was not working at
all. Florent, as you experimented a few things on that, can you give
us more details about the issues you faced ?

sami

Sami Dalouche

unread,
Sep 12, 2010, 9:44:53 AM9/12/10
to multiplefi...@googlegroups.com
Oh, and one last thing.

Do not hesitate to create a fork on github, so that we can easily see
your commits, instead of copy-pasting the code snippets here.

regards,
Sami Dalouche

florent valdelievre

unread,
Sep 13, 2010, 2:37:16 AM9/13/10
to multiplefi...@googlegroups.com
Thanks sami for these explanations.
I found this link : http://stackoverflow.com/questions/291891/how-to-cancel-a-file-upload-using-dojo-io-iframe-send
It might be possible to stop an ongoing upload by stopping the iframe created by io.iframe. I dont have time to dig deeper at the moment.

Dont hesitate to let us know what is the progress on your code Abhi ;)

Cheers

Florent



2010/9/12 Sami Dalouche <sami.d...@gmail.com>
Reply all
Reply to author
Forward
0 new messages