I'm trying out a Laravel wrapper for CloudConvert, so I'm using one of the examples from GitHub to check the basic file conversion. My code is the following:
$path = storage_path('app');
CloudConvert::file($path.'/test.jpg')->to($path.'/test.pdf');
so basically I want to convert test.jpg file to test.pdf. Both source and output files should be taken from/saved under storage/app.
Thing is, the conversion takes place but the output file is not being saved under the specified path (nor anywhere in the project). I know the conversion is successful, because I can see it in my CloudConvert account, and I can download the PDF after conversion from CloudConvert directly.
What am I doing wrong? Why isn't the output file stored?
I also tried to change the destination path to use public directory - no luck.
Related
I've been working on this setup but I cannot save the downloaded streamed response to my zip file. I am using ZipArchive package and currently when I use return on the one with the yellow arrow. It returns the correct pdf but when I try to put it in the zip folder. It doesn't recognize it as a pdf file and return null. I need to save multiple pdf file in the add Zip File but right now I'm trying with only one pdf for now.
Got it. What I did is convert it to a raw pdf file and read it using AddFromString.
I'd need to define a folder where a downloaded files is placed.
Is it possible to achieve a download into a specific folder using the force_download() function, of Codeigniter's framework?
force_download() is part of CI download helper
Generates server headers which force data to be downloaded to your
desktop. Useful with file downloads. The first parameter is the name
you want the downloaded file to be named, the second parameter is the
file data.
that said, a file will be downloaded to your designated download folder, wherever that is on your local disk. You can use this approach to make files downloadable for any user
what you are looking for is to use the CI FTP Class:
Downloads a file from your server. You must supply the remote path and
the local path, and you can optionally set the mode. Example:
$this->ftp->download('/public_html/myfile.html', '/local/path/to/myfile.html', 'ascii');
you must make sure that each time you call this to have the user supplying you with a valid local path, where the downloaded files will be stored.
I have been installed the git lib from https://github.com/Azure/azure-storage-php .
I able to figure out the create file, download file, delete file.
But how can get the file content of the file and display on browser ?
Thank you.
I'm not that much knowledgeable about PHP but I believe the SDK method you would want to use is getBlob which reads a blob and returns an object of type GetBlobResult.
Contents of the blob can be read using getContentStream() method there.
If you're using Azure Files, more or less the approach would remain the same. You would be calling getFile method which reads a file and returns an object of type GetFileResult.
Contents of the file can be read using getContentStream() method there.
Im working on a Laravel backend and I need to edit a PDF file allocated in a s3 bucket. When I try opening the PDF with $pdf->setSourceFile($url) I get an error saying Given stream is not seekable!
I can get the file contents using Storage::disk(ENV('FILESYSTEM'))->url($url);, and return it to the front end and that works fine, so I know the path and the permissions are correct. I would like to the content to the setSourceFile($contents) method, intead of the url. is there any way to do this?
By the way, Im using the Laravel filesystem
Edit: I have tried copying the file from s3 to the server and then open it with PDF. I couldn't reach it, but I don't think that's a good way to do it.
First of all: You cannot edit a PDF document with FPDI
As the error message says, the source stream needs to be seekable which seems not be the case with the stream wrapper you're currently using.
You should download the file and create a reader instance of it:
$pdf->setSourceFile(StreamReader::createByString($pdfString));
I am using a library to read XLS files which internally uses PHP's zip_open() function. When creating the files locally and then uploading to my test server everything works fine. However, when I use the XLS files downloaded from a website (normal download via browser), it does not work, instead returning Error 19 meaning that the file is not seen as a zip file, which is incorrect. Excel opens the file without problems. If I re-save the file locally as an XLSX file and then upload it, I get the same error (in this instance the file is opened by the PHP's ZipArchive class). Any ideas what the reason could be? I checked that the files are not read only, possibly some Unix permissions could be set that are not displayed in Windows? (Doubt this, as the error code indicates that the file could be accessed, but could not be identified as XLS)
Using:
Apache under Windows (WAMP)
PHP 5.4.12
It seems I had misread a line of code, the zip check is only done to determine if the XLS file is an incorrectly named XLSX file. The problem with the XLS file is that it returns no sheets when parsing, I need to look into this still. I do not know why saving the XLS file as an XLSX file (using Excel) results in an incorrect ZIP archive though, but guessing it is related.