Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Restrict upload file size  RSS feed

 
Nikes Shah
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I am finding a way to restrict file size while uploading.

Our aim is to restrict upload of X MB file without transferring file on server.

Actually we are using an open source ECM product "Alfresco", and web interface is built using MyFaces.

Is it possible to read just file properties and its size without uploading on server?

Thanks,
Nikesh
 
Tim Holloway
Bartender
Posts: 18662
71
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I believe there's a setting in web.xml that is used to do this. I don't know what the default size limit is, however. It's probably a MyFaces-specific setting, although chances are that MyFaces is using Apache Commons Fileupload to do the actual work.

The server cannot access the client file or its attributes (including the directory path). Instead, the client copies the file's contents and name into the uploaded HTTP Request datastream as part of the submit process. If, however, the amount of incoming data to the server exceeds the size limit, the server will terminate the upload. The client may include a Content-Length header for the file, which the uploaded can check. If not, the upload will proceed until the upload limit is exceeded, at which time the server will bounce the request.
 
Nikes Shah
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,

I checked in servlet which is responsible to parse http request, and fetched Content-Length header to check the size.

-Nikesh
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!