Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

Options
Go to last post Go to first unread
derekmhart  
#1 Posted : Monday, March 15, 2010 5:24:23 PM(UTC)
derekmhart

Rank: Member

Groups: Member
Joined: 3/13/2010(UTC)
Posts: 13

When users upload files, there is a limit to the total storage that each user has. I have to check this every time the File Uploaded event occurs, because the same user could be uploading files from 2 (or more) different machines. So there is a database check to check the size of the file on every file upload. I need to stop the process if the next file that is uploaded will exceed this limit. I am not sure how to do this on the server side. How can I detect when the limit is reached in the server side asp.net vb code, and then tell the client to stop the process?

And I do not see a corresponding FileUploaded event on the client, so I think there may not be a way to do this. How do I stop the server side code in FileUploaded, and call some event on the client that calls RemoveAllFromUploadList and then alerts the user to the problem. Or should I try to do this on the server code somehow? If so, how do I do this when I do not see a RemoveAllFromUploadList method, and I am not sure if I can pop up an alert.

And then I could set a flag in the server vb.net code if the storage limitation is exceed and stop the uploading of the files, but it would be great to somehow remove the rest of the files in the list. What is the way to do this. And then I was thinking I could set a flag if this has a occurred, but I tried this, and the javascript cannot read the variable. Example?

Please answer all variations of this if you can. Thank you!

Edited by user Monday, March 15, 2010 8:07:25 PM(UTC)  | Reason: Not specified

Dmitry  
#2 Posted : Tuesday, March 16, 2010 11:30:53 AM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Quote:
And I do not see a corresponding FileUploaded event on the client, so I think there may not be a way to do this. How do I stop the server side code in FileUploaded, and call some event on the client that calls RemoveAllFromUploadList and then alerts the user to the problem.

This approach can be implemented with Image Uploader. The idea is quite simple, you set up Image Uploader to upload images one per a package (you need to set ImageUploader.FilesPerOnePackageCount Property to 1). Each package is uploaded in separate HTTP POST request. Suppose you get current request on your server side. You can check whether the user quote is exceeded. If so, you return corresponding flag to Image Uploader via response. In the PackageComplete event you are able to get response sent from server and check it. If it contains the flag indicating that the user quote is exceeded, you can abort upload process and display warning to the user. To abort upload process from PackageComplete event you just need to return false from handler.
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
derekmhart  
#3 Posted : Wednesday, March 17, 2010 8:08:02 AM(UTC)
derekmhart

Rank: Member

Groups: Member
Joined: 3/13/2010(UTC)
Posts: 13

OK, I need to alter this process a bit. I have the PackageComplete event working as described below.

However, I allow the user to upload many files at once. On the server side, I determine if a given file is too large to go beyond the user's storage space. At that point, on the server side, in the FileUploaded event, I can determine if the files is too large and I can send the response Response.Write("Failed") as you suggested.

However, I do not want the user to have to wait until the file is completely uploaded first for this to happen. If the user uploads a 100MB file, all that time would incur uploading the file for the user just to find out that the space is not available.

Is there an event to use to trap this process server side WHILE THE FILES ARE UPLOADING, not in the FileUploaded event? Isn't the file already uploaded at that point when it reaches the FileUploaded event (I know it is just in the asp.net temp cache at this point).

And then if I can pick up the bytes of the file server side before it uploads, I am not sure what to do. I looked at the OnClientPackageBeforeUpload event, but that does not have the ResponsePage parameter, so I have no idea how I would stop the uploading from happening.

If the above is possible, I would like to take this a step further. It would be great to tell the user that a file has been reached that is too large, but ask the user if he/she would like to continue uploading the rest of the files (because some of the files might be smaller and might not go beyond the storage space). Do you have some thoughts or sample code on that?


Tamila  
#4 Posted : Wednesday, March 17, 2010 3:20:48 PM(UTC)
Tamila

Rank: Advanced Member

Groups:
Joined: 3/9/2008(UTC)
Posts: 554

Was thanked: 1 time(s) in 1 post(s)
Hi,
Quote:
Is there an event to use to trap this process server side WHILE THE FILES ARE UPLOADING, not in the FileUploaded event? Isn't the file already uploaded at that point when it reaches the FileUploaded event (I know it is just in the asp.net temp cache at this point).

And then if I can pick up the bytes of the file server side before it uploads, I am not sure what to do. I looked at the OnClientPackageBeforeUpload event, but that does not have the ResponsePage parameter, so I have no idea how I would stop the uploading from happening.

If the above is possible, I would like to take this a step further. It would be great to tell the user that a file has been reached that is too large, but ask the user if he/she would like to continue uploading the rest of the files (because some of the files might be smaller and might not go beyond the storage space). Do you have some thoughts or sample code on that?

Unfortunately, it is impossible. You cannot interrupt upload process. It is impossible due to server restrictions. Server works in following way:
The first transaction is to receive POST-request completely.
The second transaction is to parse POST-request.

So you cannot interrupt POST-request receiving.

Also where is no way to continue upload process if some uploaded file was not acceptable and you return false from PackageComplete event. You customers need to start upload the files again.

By the way, as I understand you got working the method which Dmitry described before. If you have any problems with it please let us know.
Aurigma Support Team

UserPostedImage Follow Aurigma on Twitter!
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.