I usually don't post any question on Stack Overflow because I always find an answer to whatever problem I'm in trouble with. But here, I haven't found a clear answer so if you can help me, thanks a lot !
I'm working on a Symfony 3.4 website. I've made a script inside my controller to return a file as a BinaryFileResponse.
$response = new BinaryFileResponse($pathtofile);
$response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, $filename);
return $response;
At first, the downloading process works ok, but just at the end, an error occurs. Chrome returns a "Network error" failure and the downloaded file stays as a .crdownload instead of being rename as an .mp3 in my case. (Note : If I rename manually the file as an .mp3, it plays correctly.)
I've searched for a possible issue on the content-length property of the headers, but it seems to be sent correctly when I check the Symfony Profiler Capture here
I've found a way to bypass this error by using a stream as mentionned in the Symfony Docs, like this :
$stream = new Stream('path/to/stream');
$response = new BinaryFileResponse($stream);
My file is served by a PHP script, but it is not generated by it. Is there a way to serve it as a static file instead of a stream ?
With the stream solution, the client can't see the actual size of the file, which is not really user friendly. Also, it is really slow.
Thanks for your help !
EDIT : the first solution works on localhost, but not on prod server.
Related
I am using the Laravel filesystem calls - for example: Storage::disk('sftp')->put and it is working fine but I am wondering how I can view debug or error information if there ever were the need?
So for example if the file upload failed, how would I see that? When I first wrote the code it was not working and there was no Laravel exception screen and nothing in the laravel.log.
I'm in the same case.
I'm using Laravel Storage library with league/flysystem-sftp for sftp transfer. Here is the problematic line.
Storage::disk(self::REMOTE_DISK)->putFileAs($destFolder, $this->localFilePath, $destFilename);
Most of the time all is working fine. File is copied from local to remote without any problem.
But sometimes one problem occurs and I failed to understand what's occured during the transfer.
All I can do (at this time) is
$result = Storage::disk(self::REMOTE_DISK)->putFileAs($destFolder, $this->localFilePath, $destFilename);
if ($result === false) {
$exception = new FileUploadFailureException("file upload has failed");
}
Is there a better way to debug one sftp connection trouble ?
I´ve written a tool using PHPseclibs SFTP solution to uplaod various files to different target server. All targetserver are using wingFTP.
Under some conditions the upload fails without giving any debug message or error code.
I could figure out that the error (if it occures) allways occures in the following line of my code:
[...]
if(!$sftp->put($aResult[0]["targetpath"] . $sFilename, EXPORTFOLDER . "/" . $sFilename, NET_SFTP_LOCAL_FILE)){
[...]
Is there any way to see what is happening? There are no error messages or something... can I configure debug/error messages while using PHPseclib somewhere?
In about 95% of all cases the Upload is successfull and it does not only appear on one target server or for one file. Does someone have an idea where the problem could be located?
I am using the Loopj AsyncHttpClient for Android and it works like a charm.
Now I am trying to upload three small images to my server, and I am having some problems.
It is very weird because it works perfectly if I upload 2 images, but when I try to add a third to the same request, the server response is the error 3 for file uploads:
UPLOAD_ERR_PARTIAL
Value: 3; The uploaded file was only partially uploaded.
So when I do this:
params.put("photo1", f1);
params.put("photo2", f2);
it works...but when I add a third:
params.put("photo1", f1);
params.put("photo2", f2);
params.put("photo3", f3);
the server fails to process the request...
I have checked the files, the server side app seems to work fine (I tried sending the data with postman and it works)
Do you know why AsyncHttpClient would fail uploading 3 files but succeed uploading 2??
thanx in advance
This problem has been introduced with version 1.4.4 of this library. I did not have time to dig deeper yet, but I suspect this particular commit: https://github.com/loopj/android-async-http/commit/9f73dc722fdf8b564bf1487eef395d0b7e4ae862 to be responsible for this issue.
As a workaround, use version 1.4.3 for now. It should work fine.
I got a similar problem after update to 1.4.4. If I upload 2 images, the server will only get 1 image (if 3, will get 2). After search and testing, I know the server, my code and 1.4.3 are ok.
Today I try this:
params.put("photo1", new FileInputStream(f1));
params.put("photo2", new FileInputStream(f2));
params.put("photo3", new FileInputStream(f3));
It works.
I'm trying to use the template from http://jenkins-php.org in my installation of Jenkins. As soon as I go in to configure the project I get a grey screen appearing and the words 'Loading'
If I look in the Browser error console I get TypeError: 'undefined' is not an object (evaluating 'registry.get')
Has anyone else experienced this problem? How can this be fixed?
We had this problem when upgraded to 1.528.
Digging further, we found out that the problem is originated from one of the client-side script files called "hudson-behavior.js" and is caused by the "Publish Over SSH" plugin. There have been other plugins that have caused this in the past, as well. We couldn't disable the plugin anyway. So we searched further.
Long story short, we ended up changing the script for the time being. If you, like us, install Jenkins using the war file, then the script file is probably extracted and cached in "/var/cache/jenkins/war/scripts/hudson-behavior.js".
The following change we made was in a function called "registerValidator":
if (depends==null) { // legacy behaviour where checkUrl is a JavaScript
try {
return eval(url); // need access to 'this', so no 'geval'
} catch (e) {
// set depends to an empty array.
depends = [];
}
}
var q = qs(this).addThis();
The URL may not always be valid. Thus, a try-catch is in order. Hope this helps!
I've just had the same issue, I'm using version 1.523 of Jenkins on an Ubuntu server.
The solution I found was to manually edit the project config.xml file.
sudo vim /var/lib/jenkins/jobs/yourProjectName/config.xml
I had images in the description and I removed those leaving the description tag empty.
I also had an empty plot section which I removed completely from the publishers section.
After saving the config and going back to 'manage Jenkins' and then 'Reload Configuration from Disk' I then reopend my project and the config opened normally again.
I wasn't getting quite the same error message as you in the browser console to start with, but I hope that helps.
I too downgraded to 1.523 and then it worked... So it's obviously some bug introduced after 1.524.
Upgrading from 1.530 to 1.531 fixed it for me.
I am looking for help with this problem and I hope someone give me that help. The error is the following:
Fatal error: SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://example.com/index.php/api/?wsdl' : failed to load external entity "http://example.com/index.php/api/?wsdl" in
/var/www/presentacion/app/code/local/Pengo/Extension/Model/Something.php on line 28
And the code that I'm using to connect to it is something like this:
$this->_soap = new SoapClient(http://example.com/index.php/api/?wsdl);
and there is where it says is the error.
I have been serching in Google, PHP forums, here in StackOverflow and Magento itself but I don't find the solution anywhere.
What I had seen is that the WSDL is never get parsed or loaded as the error says and none of its functions.
I tried connecting like this:
$options['location'] = http://example.com/index.php/api/?wsdl;
$options['uri'] = 'urn:Magento';
$this->_soap = new SoapClient(null, $options);
like this it doesn't dispatch any error like the others but there aren't functions to use, like in the other case it doesnt' load and parse the WSDL.
I am a bit frustrated because I have been developing this like 1 month and now that I am making some tests it shows this message, I had test it when it was really empty and new and it worked fine.
So any help would be appreciated.
Thank you.
Nine times out of ten this error is Magento is telling you it can't load the WSDL file. Magento is telling you this. It's not your local client code that's complaining.
Magento uses the PHP SoapServer object to create its SOAP API. The SoapServer object needs to access the WSDL as well. Try running the following from your server's command line
curl http://example.com/index.php/api/?wsdl
If I'm right, the above will timeout/fail.
Because of some quirks in DNS, it's surprisingly common that a server won't be able to access itself via its domain name. If this is the case, the quickest fix is adding an entry to the server's hosts file. (Talk to your server admin if none of that made sense)
Well after all the things that I test the only one that worked for me, I don't know why but it worked, was doing this in two separate machines. I tried that because I read that somewhere and I just do it and my Magento and Webservice now works perfectly. Whenever I try to do this local it dispatch the same error.
I hope this can help someone in the future and they don't have to knock their head on the wall because of this problem.
Thank you all for your answers and comments.
Alan Storm is right on the Money here!
Make sure that you check your server Hosts File, and that it includes an entry for both domain and www.domain. Espicialy important if you are doing server rewrites.