Fieldtype, Module

Archived
Forum
(read-only)

Protected Links

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Yuri Salimovskiy

1 of 2
1
   

memory size error

Support Request

yann
yann

I tested this add-on on my dev version of the site and it worked beautifully… Only problem is… I tested with small files locally… Not that I just put the site live and that the protected links link to music files for sales, I get this error:

Fatal errorAllowed memory size of 134217728 bytes exhausted (tried to allocate 126291048 bytesin /.../system/expressionengine/third_party/protected_links/mod.protected_links.php on line 214 

I tried to add up to 128MB of memory via php.ini but it doesn’t fix the issue. The downloadable file is 515MB. Nowhere did I read that this add-on worked only on small files nor did I imagine that it mattered… Does it? The site went live and is completely broken… Any help MOST appreciated… Thanks!

Yuri Salimovskiy
# 1
Developer
Yuri Salimovskiy

If you’re serving large files, it is highly recommended to use “local” mode and not URL. Are you able to convert URLs to local path? That should solve the problem.

yann
# 2
yann

Just in case someone runs into same problem:

storage="local" 

does the trick indeed.

Thanks!

Seb
# 3
Seb

Thanks Yann. We’ve just run into this problem. On a 300MB file to download, Protected_links was demanding another 300!

Seb
# 4
Seb

Spoke too soon. We can’t use local files because we’re storing them, through Channel Files, on an Amazon S3 Bucket. Our Protected_Links tag looks lie:

{exp:channel_files:files entry_id="{entry_id}"}
<a href="{exp:protected_links:generate url="link="yes"hotlink="yes"lock="yes">Download</a>
{/exp:channel_files:files} 

I just tried adding storage=“S3” but I get a blank screen if I click on the links.

Any clues?

Yuri Salimovskiy
# 5
Developer
Yuri Salimovskiy

Hi Seb,

when serving files from S3, you need to provide storage=“s3” parameter (make sure it’s lowecase). Also you’ll need bucket name specified as “container” parameter (ex. container=“mybucket”) and actual file name (only file name, without bucket name) as value of “url” parameter.

If you get blank screen, try setting EE debug preference to show errors to everyone and check whether you see any errors.

Seb
# 6
Seb

Thanks for that Yuri.
I’ve given it a whirl. The links work now but when I click and download the zipped file it’s empty: ie when I unzip it it spits out a zero KB .cpgz file.

I’ve followed the advice on a previous post that had a similar issue. But that hasn’t resolved it. I’ll do some more testing.

Yuri Salimovskiy
# 7
Developer
Yuri Salimovskiy

Try setting EE debug preference to “show errors to everyone” and then open that .cpgz file with a text editor and see if there’s some message in it

Seb
# 8
Seb

Thanks. I’ll set debugging in a second. In the meantime this is what the .cpgz file contains:

<h4>A PHP Error was encountered</h4>

<
p>SeverityUser Warning</p>
<
p>Message:  S3::getObject(domainNamefilename.zip): [PermanentRedirect] The bucket you are attempting to access must be addressed using the specified endpointPlease send all future requests to this endpoint.</p>
<
p>Filenameamazon/S3.php</p>
<
p>Line Number222</p>

</
div><div >

<
h4>A PHP Error was encountered</h4>

<
p>SeverityWarning</p>
<
p>Message:  fclose(): 40 is not a valid stream resource</p>
<
p>Filenameprotected_links/mod.protected_links.php</p>
<
p>Line Number267</p

Hmm. Endpoints. I’ve seen this issue before. Our bucket is in Europe and something about Protected_Links and Amazon buckets in Europe don’t work.

Yuri Salimovskiy
# 9
Developer
Yuri Salimovskiy

I’m not sure what it “endpoint” it S3 terms, but my guess is that you need to use some sort of “alternative” name for this bucket. Do you have any idea what that would be?

Seb
# 10
Seb

Something similar happend as described here. And doing some research I concluded that ‘something’ (either Channel Files, Protected Links, the server environment) preferred using US Buckets and not Europe based ones. Unfortunately I think we’re obliged to use European buckets. Hmm

Yuri Salimovskiy
# 11
Developer
Yuri Salimovskiy

The S3/endpoint issue has been taken care of in latest release. You are now able to select S3 endpoint when creating link (in other words, you can select “Europe” in CP, or set endpoint=“s3-eu-west-1.amazonaws.com” parameter on frontend)

Seb
# 12
Seb

You’re a hero. I’ll give this a whirl now.
Thanks,
Seb

Seb
# 13
Seb

Dang. I upgraded the addon and added the extra europe endpoint parameter. However, when I click on the link I receive an application_force-download.html with the following error message.

A PHP Error was encountered
Severity
User Warning
Message
S3::getObject(bucketnamefilename.zip): [6] Couldn't resolve host 'filename.zip'
Filename: amazon/S3.php
Line Number: 222

A PHP Error was encountered
Severity: Warning
Message: fclose(): 36 is not a valid stream resource
Filename: protected_links/mod.protected_links.php
Line Number: 272 
Yuri Salimovskiy
# 14
Developer
Yuri Salimovskiy

What exactly is filename.zip? For some reason S3 library is trying to parse it as full URL, which is kinda weird…
The URL parameter of tag should contain only the actual file name

Seb
# 15
Seb

filename.zip is a zip file in the s3 bucket that I renamed in the pasted code above to remain anonymous – my client is sensitive about security. The zip file contains videos and documents. Anything else I can do / try?

Just to double check, the link code looks like this:

{exp:channel_files:files} 
 {exp
:protected_links:generate 
   endpoint
="s3-eu-west-1.amazonaws.com" 
   
storage="s3" 
   
container="bucketname" 
   
url="{file:filename}" 
   
only_link="yes" 
   
ip_lock="yes" 
   
deny_hotlink="yes"}
{
/exp:channel_files:files} 

I wonder if one of my htacces rules is causing the error.

1 of 2
1