Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

SS 3. Limit on the total size of the user downloaded files

Go to End



Community Member, 5 Posts

14 September 2012 at 8:31pm

There was a need to display the size of the downloaded user file, and I have decided it is simple:

SomeFunction { 
 $userID = Member :: currentUserID (); 
return File :: get () -> filter (array ("OwnerID" => "$userID")); 

and in the template as follows:

<% Control SomeFunction%> 
File Name: $Name | File Size: $Size 
<% end_control%> 

And there were no questions.

But there is another need - to prevent a user to download a file, if it has already reached the limit on the total size of all files, for example, the limit of N mb. I read the manual, but did not understand what to do. If the table "File", it would be a field "Size", I think I would have found the answer, but it is not there :-) Should I use $Size somewhere inside SomeFunction? Tell me, please, what to do? :-)
Can I do without creating an extra class File (for example, UserFiles extend File)? :-)