Change upload limit for files

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #307920

It is possible to change file size on front-end product creation?
I need to change it dynamically depending on user group.
A lot of thanks for your help!!

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 9 months ago #307939

Hello,

There is no setting in the current HikaMarket version to override the max upload file size per vendor group.
In HikaShop 3.5.0, the uploader javascript library got an update with various improvements ; one of them was a better support of the upload limitations (know the different between the server limitation and the limitation we want).

In HikaMarket, there is some "waiting" code in order to have an upload limitation size in the server side.
The idea is to modify the line

$options['max_file_size'] = null;
in the HikaMarket product controller.

But the user won't see that upload limitation since it's all coming from the uploader javascript lib which is in HikaShop.
I think that it would require some modifications in the HikaShop uploader type so it would have options to tweak these values.
But, if you do set the max_file_size in HikaMarket, the restrictions will be applied on server side, so the upload will be refused if the file is bigger than the set-up value (that you can make it dynamic depending the vendor group).
Of course the best would be to have an options like the other "vendor options" that you can find in the HikaMarket backend ; but I would highly prefer to also have the option available in the uploader type so the vendor will be aware of the restriction before it starts the upload and more than a text within the uploader zone.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #307945

Perfect. Making modifications to this line $options = null; is perfect.
There is a way to make this modification without edit the core code maybe with a plugin?

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 9 months ago #307981

Hello

There is no trigger in the HikaMarket product controller (and there is not a lot of triggers within controllers).
But I guess that it could be interesting to have a trigger for that, not in the HikaMarket product controller but in the upload one.
Thanks to that, by modifying one single file you will have access to every section which is using the upload system, even plugin controllers !
The idea is to place the trigger call just after the :

... = $this->controller->getUploadSetting(...
And regarding the parameters, I think it will be interesting to have the $uploadConfig, $this->controller, $upload_key and $caller.

I'll add a feature request ticket in my side.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #307990

Perfect. Thanks for your help Jerome.
Best Regards !!

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #307992

I just have another question but let me know if I need to open another Topic. There's a variable like $options to modify file extensions?
Best Regards!!

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #307993

Do you have an idea why this code just works for 20MB limit?
$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id);
$seller_premium_group_id = 12;
$search_group = array_search($seller_premium_group_id, $groups);
if($search_group != false) {
$options = 1048576000;
} else {
$options = 209715200;
}
The idea is all groups that are not Premium Seller can upload files 200MB max and Seller Premium up to 1GB. The thing is the 200MB doesn't works, but for example if I set the limit to 2MB it works well, just doesn't works when I try to limit bigger files.

Last edit: 4 years 9 months ago by OPHWD.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 9 months ago #308013

Hello,

I'm sorry but between the code and your number, I'm not able to understand what is going on.
Right now, I don't see the relation between the code you pasted (please use the "code" tag for that) and your limitation issue.
Afterwards, you're talking about 200MB, 20MB and 2MB but it's not possible to understand the context or else.
Nor to understand "doesn't works" means.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 9 months ago #308039

$user = JFactory::getUser();
$groups = JAccess::getGroupsByUser($user->id);
$seller_premium_group_id = 12;
$search_group = array_search($seller_premium_group_id, $groups);
if($search_group != false) {
$options = 1048576000;
} else {
$options = 209715200;
}

Yes you are right. So sorry, I will try to explain me better. When I say "doesn't work" means if I set limit to 209715200 B (200MB) I can still upload files bigger than 200MB. But I set the limit to 2097152 B (2MB) the limit it works well and any file bigger than 2MB successfully get and error about file limit size restriction.

Last edit: 4 years 9 months ago by OPHWD.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 9 months ago #308042

Hello,

Thanks for the clarification !

The problem is related to the chunk system, the first check is made when the upload is made but only on the chunk size ; so if you have multiple chunks, you need to add another test.
In the administrator/com_hikamarket/helpers/upload file you need to replace

	} else if(!empty($this->options['max_file_size']) && $file->size > $this->options['max_file_size']) {
		$file->error = 'maxFileSize';
By
	} else if(!empty($this->options['max_file_size']) && $file->size > $this->options['max_file_size']) {
		$file->error = 'maxFileSize';
	} else if(!empty($this->options['max_file_size']) && isset($slice['total_size']) && $slice['total_size'] > $this->options['max_file_size']) {
		$file->error = 'maxFileSize';

And the limitation will be made too.
(We will add that patch in our side too)

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 8 months ago #308305

Works perfect. A lot of thanks for your help !!

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 5 months ago #312154

Hi Jerome. How are you?
I just wondering. It is possible to use the new triggers on 4.2.1 release for this goal?
onBeforeFileCreate onBeforeFileUpdate onAfterFileCreate and onAfterFileUpdate.
A lot of thanks for your help.

Please Log in or Create an account to join the conversation.

  • Posts: 25994
  • Thank you received: 4004
  • MODERATOR
4 years 5 months ago #312195

Hello,

I'm not sure that HikaShop have the patch for that.
Best would be to ask the HikaShop support team, via the HikaShop section of the forum.

Regards


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 19
  • Thank you received: 0
4 years 5 months ago #312206

Thanks for your great support Jerome. I'm opening a new case on HikaShop.
Have a great day !!

Please Log in or Create an account to join the conversation.

Moderators: Obsidev
Time to create page: 0.083 seconds
Powered by Kunena Forum