$mailer->addAttachment() not sending (or timing out) large files - joomla

Currently I am able to send attachments using Joomla
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
...
$mailer->addAttachment($filepath);
I am able to send attachments of very small sizes (I've tested 1-100KB of different file types INCLUDING .pdf) but when I tried to attach a 1.7mb pdf file. The page stops loading after some seconds then white screen. I tried to check in developer mode and it says ("Failed to load response data.").
Do you guys know how to go about this? Is this a max upload issue or the request just timed-out maybe because of the slow upload?
Thanks in advance.

Related

MPDF in Laravel can't output (inline) pdf

I am doing below code in Laravel 5.5 with mpdf 8.0
$mpdf = new \Mpdf\Mpdf();
$mpdf->WriteHTML('Hello World');
$mpdf->Output("test","I");
It outputs gibberish/garbage values, seemingly showing pdf file in raw form.
Some findings
If I use $mpdf->Output($reportPath, 'F'); (saving it to file) and the opening that. It opens the file as expected.
If I place die(); after $mpdf->Output("test","I"); it shows the document.
My suspicion is, it has something something to do with Content-type:application/pdf not being set by default but I have also tried using header("Content-type:application/pdf"); before Output but of no use. it is still showing Content-Type: text/html; charset=UTF-8 in response header in Network tab of chrome (also tried Firefox).
Some back-story
It used to work on php7.3 just fine, but I have to update it to php7.4 due to some library and multiple application on a single server scenario.
Also start using a sub-domain for my application instead of placing the directories after the domain.
I'm looking for
A solution that doesn't require me to place die; at the end of output.
Or some clue in on why this has started happening or/and perhaps why I need to place die; after Output.
Any other solution.
The goal is to provide some ref. for people encountering same issues in future, since I have spent hours and haven't anything that specifically address such issue.
Ok, so I found out that I can't just rely on $this->mpdf->Output('test.pdf',"I") to output my result (though it was working previously with the same line) to the browser.
Because for some reason it has started to send Content-Type:text/html value in Content-Type header so I had to change that.
Solution
I did it as below:
return response($this->mpdf->Output('test.pdf',"I"),200)->header('Content-Type','application/pdf');

iOS8: NSURLSession: NSURLSessionDataTask 'Client closed connection before receiving entire response'

I use iOS BACKGROUND FETCH n BACKGROUND TRANSFER to update our app.
When we download an MP4 as part of a large download of lots of files the download can stop suddenly and get error:
'Client closed connection before receiving entire response'
http code is still 200.
We have no limit on data due to corporate cellular accounts and have single apps on our iPad so management want us to download a larger amount of data and number of files sometime over 20/30 on a clean install.
They're corporate videos/ pdfs published daily.
I created a NSURLSession
NSURLSession * backgroundSession_ = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:identifier]
Then for each URL to the mp4 or PDF I create a NSURLSessionDownloadTask from my NSURLSession
NSURLSessionDownloadTask * downloadTask_ = [backgroundSession_ downloadTaskWithURL:url_];
The fire off resume on each download task.
When all return the NSURLSession completes and I tell the user in a notification that the apps has been updated.
I use CHARLES PROXY on my mac to monitor the downloads.
It takes a while as there are many files and also I noticed the movies seem to stream so can be slow.
Usually it checks whats been downloaded and only downloads the latest but if I do a lot of downloads say to a clean install I noticed that quiet often the streams to the mp4 get killed.
They have a 200 code but with message
'Client closed connection before receiving entire response'
Any idea what may cause this because it can stop my NSURLSession from completing so my sync can get in a sort of hung state.
IMAGE: OK DOWNLOAD: MOVIE STREAMS AND SAVED TO DISK: 200: Complete
IMAGE: DOWNLOAD SUDDENLY STOPS:
Any ideas: I use Background Fetch so not sure if the client in the message is iOS8 or my app.
After each downloadtask returns I copy the tmp file to mp4 in documents and call
[session finishTasksAndInvalidate];
if some of these downloadtask fail then I notice the session never finishes and gets stuck.
When I do another fetch I get all these old download task and old sessions.
was asked how I solved this but two years laster.
We also shrunk the movie files as well to speed up downloads.
I also remember the session and the configuration having separate settings. I had set header in one but failed when iOS 8/9 came out as it should have been set in the session not just the config - but may be fixed now as iOS 10 out
//-----------------------------------------------------------------------------------
//some movie streams time out n get
//'http://stackoverflow.com/questions/23428793/nsurlsession-how-to-increase-time-out-for-url-requests'
//'Client closed connection before receiving entire response'
NSLog(#"urlSessionConfigurationBACKGROUND_.timeoutIntervalForRequest:%f", urlSessionConfigurationBACKGROUND_.timeoutIntervalForRequest);
NSLog(#"urlSessionConfigurationBACKGROUND_.timeoutIntervalForResource:%f", urlSessionConfigurationBACKGROUND_.timeoutIntervalForResource);
//was 60
//urlSessionConfigurationBACKGROUND_.timeoutIntervalForRequest = 240.0;
urlSessionConfigurationBACKGROUND_.timeoutIntervalForRequest = 600.0;
// urlSessionConfigurationBACKGROUND_.timeoutIntervalForResource = 60.0;
You can ask your server mate to change the content-type to video/mpeg4 or you can change your request type from GET to POST

Newsletter tracking image Outlook

I have a newsletter system that keeps track of the people who read it. Although this function works only if permission is given to download the images. But this is not my problem at this time.
My problem is that when I open an newsletter in Outlook (2010) and I give permission to download the images, my system doesn't register this view. But when I open the same newsletter in gMail, it works without any problem. Even when I use Outlook to save the e-mail to a HTML file and I open this file, a new view is registered. The page that save's the view and renders an 1x1 image, doesn't return any errors and no errors can be found in the Apache logs.
The strange thing is that it still worked until a week ago. But even if I put backups of the code, it still doesn't work....
The image url is build up with an base64 encodes string, for example:
http://domain.com/tracker/eyJtYWlsaW5nSWQiOiI4MjQiLCJjb250YWN0SWQiOjM3MzA5LCJjaHVuayI6ImIyYmNiNzhkNjAyMmVmNzQ0NmM4ZDA0YzU1ZGZhMTY0In0=/
In this encodes string, I have a JSON string that contains the newsletter id, a contact id and a MD5 string which I use to validate the data.
I run of ideas what to do to fix or debug this issue. Does anyone have a tip or even better, a solution? :) It it possible that Microsoft updated Outlook to prevent it from downloading this kind of images?
Check if you are sending correct MIME
I suggest using extensions in url example: .png .jpg
Try different domain.
This is the code for generating the image:
header('HTTP/1.0 200 Ok');
header("Content-type: image/png");
$trackerImage = imagecreate(1, 1);
$bgColor = imagecolorallocate($trackerImage, 255, 255, 255);
imagepng($trackerImage);
imagedestroy($trackerImage);
This always worked until a hardware crash of the server 2 weeks ago... The hosting company claimes nothing has been changed to the servers configuration.
I already tried adding an extions to the image path, but that didn't make a difference for Outlook.
Try to set the HTML code to display the image as if it's a larger image. Or even better, just display a normal image along.
I just happen to resolve this issue. The cause appeared to be fairly simple, but very difficult to detect.
When saving data about a user, I also requested the user-agent. In the database, I had a varchar (255) field in use for this information. However, the user-agent Outlook proved to be more than 255 characters. So this resulted in an error message from the database so that no image was generated.

Chrome GET request cancels and restarts continously

I am trying to play an mp4 video on my website using window.location = path-to-file/file-name.mp4 through Chrome. Although the video plays, Chrome Developer Tools Network tab shows that that the request continuously gets cancelled and resent:
.
I have left the Developer Tools window open and it has shown that more than 5000 requests have been made and over 600 MB transferred :
It's beyond me why this is happening. I have tried looking at the the request and response headers for the first 4 requests to see if I could spot something obvious (I am by no means an expert):
and the only thing I can see is that the RANGE and CONTENT-RANGE in the request and response headers, respectively, seems to be changing. I also noticed that the very first response has TRANSFER-ENCODING set to CHUNKED.
I tried researching these terms but was not able to come to any conclusions (except the one that I still have a lot to learn, haha). If anyone could please provide any help or point me in the right direction I would be most appreciative :)
Thanks for your help!
EDIT : I would like to add that I am not explicitly creating a GET request with XMLHttpRequest, just using window.location to play the video in a new window.

How can I scrape an image that doesn't have an extension?

Sometimes I come across an image that I can't scrape so that it can be saved. An example of this is:
https://s3.amazonaws.com/plumdistrict.com-production/perks/12321/image/original.?1325898487
When I hit the url from Internet Explorer I see the image but when I try to get it from the code below I get the following error message "System.Net.WebException The remote server returned an error: (403) Forbidden" error with GetResponse:
string url = "https://s3.amazonaws.com/plumdistrict.com-production/perks/12321/image/original.?1325898487";
WebRequest request = WebRequest.Create(url);
WebResponse response = request.GetResponse();
Any ideas on how to get this image?
Edit:
I am able to get to save images that do have extensions. For example I can scrape the following image just fine:
https://s3.amazonaws.com/plumdistrict.com-production/perks/12659/image/original.jpg?1326828951
Although HTTP is originally supposed to be stateless, there are a lot of implementations that rely on it being stateless. I could configure my webserver to only accept requests for "http://mydomain.com/sexy_avatar.jpg" if you provide a cookie proving you were logged in. If not, I send you a redirect 303 to "http://mydomain.com/avatar_for_public_use.jpg".
Amazon could be doing the same. Try to load the web page using Chrome, and look at the Network view in developer mode (CTRL+SHIFT+J) to see all headers supplied to the website. Maybe you even need to do a full navigation in the same session before you are allowed to see the image. This is certainly the case in many web applications I have developed :-)
Well, it looks like it's being generated from a script (possibly being retrieved from a database). The server should be sending a file/content type to go along with that... but it doesn't seem to be, which I believe is a violation of standards.
My Linux box knows full well that that's a JPEG image once it's on my hard drive, because it examines file headers rather than relying on extensions. Perhaps there is a tool to do the same in Windows?
Edit: Actually, on further contemplation, it seems odd that you'd get a 403 for that. Perhaps the server is actually blocking you from retrieving the file in that manner.

Resources