I am trying to get specific metadata of an image located in dropbox using PHP and the Dropbox API.
After I connect to dropbox and list the images, I do this:
$md = $dbxClient->getMetadata($path);
print_r ($md);
Where the $path is the directory to my image. This works perfectly but I need to get more metadata regarding GPS location. In the Dropbox API (general view for Python, PHP, Java etc.) it says I have to set "include_media_info" to true to get gps metadata.
Going to the PHP part it has the function GetMetaData() with only one parameter: string
($path The Dropbox path to a file or folder).
Is there a way to get detailed metadata using the Dropbox API for PHP?
As you noted, the PHP library doesn't support the include_media_info parameter, so you'd need to modify the source code of the library to add support.
E.g. you could add this method:
function getMetadataWithMediaInfo($path)
{
Path::checkArg("path", $path);
return $this->_getMetadata($path, array("include_media_info" => "true"));
}
I had a look at the source, try this:
$md = $dbxClient->_getMetadata($path,array("list" => "true"));
or edit the core getMetadata and change its hard coded parameter list to true
Related
I am working on a PHP app on Google App Engine standard environment.
I upload an image to the app's associated bucket, then use this code to serve the image:
use \google\appengine\api\cloud_storage\CloudStorageTools;
// ...
$path = "gs://my-app.appspot.com/the_image_name.jpg"
$imageUrl = CloudStorageTools::getImageServingUrl($path, ['secure_url' => true, 'size' => 0]);
header("Location: $imageUrl");
There is of course a redirection to a page like this:
https://lh3.googleusercontent.com/<some_hash>
The image displays correctly, but in the title of the browser it says "unnamed.jpg", and when I try to save the image to my computer the default name appears as "unnamed.jpg". This happens every time I upload an image, no matter its actual name, or if I do upload it through my app using the API or if I upload it directly to the bucket through the web cloud console.
Is there any way in which I can specify what name is used when serving the image?
Did you set the headers: 'Content-disposition', 'Content-Transfer-Encoding', & 'Content-Type'
CloudStorageTools::getImageServingUrl uses googleusercontent.com which is a "sandbox" and therefore you can't change the name of the file served.
I suggest you to take a look in CloudStorageTools::serve method where you will be able to set the name of the file with save_as parameter. Please note that the type is string and not boolean as it's mentioned in the documentation and serve will take some app engine compute time.
The code should look like this:
use \google\appengine\api\cloud_storage\CloudStorageTools;
// ...
$file_name = "gs://my-app.appspot.com/the_image_name.jpg"
$options = ['save_as' => 'the_image_name.jpg'];
CloudStorageTools::serve($file_name, $options);
I am using Php PDFLIB to generate the pdf in my application I have gone through its block api by which we can define the block in pdf and we can populate that block values from db values
Eg::
http://www.pdflib.com/en/pdflib-cookbook/block-handling-and-pps/business-cards/php-business-cards/
I wanted know is there way we use the pdf loaded from AWS s3 link instead of storing that in Searchpath
i.e instead of the lines that says
$infile = "businesscard_blocks.pdf";
can we load something
$infile = aws/s3/path/businesscard_blocks.pdf
you should check out the PVF feature of PDFlib. With the PVF you can load resources from memory. So you create a named mapping between a variable data and file name.
So in your case you might load the data from AWS via a PHP function
$PDFfiledata = file_get_contents('https://XYZ.AWS.com/aws/s3/path/businesscard_blocks.pdf');
$p->create_pvf("/pvf/input.pdf", $PDFfiledata, "");
$doc = $p->open_pdi_document("/pvf/input.pdf", "");
then you can go ahead, as when you load the file from disc.
Please see the starter_pvf sample (http://www.pdflib.com/de/pdflib-cookbook/general-programming/starter-pvf/php-starter-pvf/) and PDFlib 9 Tutorial, chapter 3.1.2 "The PDFlib Virtual File System (PVF)"
I'm new to Zend's Apigility and I have problem with file upload.
I've created a new rest service and configured fields in the admin UI as described in Apigility documentation: https://apigility.org/documentation/recipes/upload-files-to-api
When trying to obtain any data from InputFilter i get only null values.
Resource controller
public function create($data)
{
$inputFilter = $this->getInputFilter();
$data = $inputFilter->getValues();
var_dump($data);
//return $this->attachments->create($data);
}
var_dump result
array(1) {
["filedata"]=>
NULL
}
For testing purposes I'm using Postman extension for Chrome with Content-Type header set to 'multipart/form-data', and attached file to key: filedata.
I'm pretty sure, I can send files using json and base64_encode, but I would rather hold with it until it would be absolutely necessary.
For those who aren't aware, Apigility is a Zend Framework 2 based framework specifically made for Rest/Rpc API's.
To do file uploads, please refer to their documentation on the recent updates as noted by Jon Day.
Credit : https://apigility.org/documentation/recipes/upload-files-to-api
How can you allow uploading files via your API?
Answer
Zend Framework 2 provides a variety of classes surrounding file upload
functionality, including a set of validators (used to validate whether
the file was uploaded, as well as whether it meets specific criteria
such as file size, extension, MIME type, etc.), a set of filters (used
to allow renaming an uploaded file, as well as, more rarely, to
manipulate the contents of the file), and file-upload-specific inputs
for input filters (because validation of files needs to follow
different rules than regular data).
Currently the limitation is that Apigility will only accept multipart/form-data
Using Xdebug I am getting the following out :
$data_array = $inputFilter->getValues();
$image = $data_array['images_data'];
The $image array looks like this :
name = MemeCenter_1400658513231_337.jpg
type = image/jpeg
tmp_name = /tmp/phpzV3mWA
error = 0
size = 379580
Try this
Update apigility with composer. File upload is working in version 1.0.3
Use Postman to send files but with no headers.Just select form-data.It worked for me.
To move uploaded file use rename instead of move_uploaded_file.
You can use the option ('magicFile' => false) for the MimeType validator which fixes the problem without any modification at the zf library.
I'm writing a web app that at one point allows a user to upload a photo to a flickr account (mine). I want to do this without saving the intermediate image on the server my web app is on.
What I've got so far is a page which implements phpFlickr and accepts a POST from a simple html form. I use $_FILES['file']['tmp_name'] as the path for phpFlickr to use. Here's the code:
<?php
require_once("phpFlickr.php");
$f = new phpFlickr("apikey", "secret", true);
$_SESSION['phpFlickr_auth_redirect'] = "post_upload.php";
$myPerms = $f->auth("write");
$token = $f->auth_checkToken();
$phid = $f->sync_upload($_FILES['file']['tmp_name']);
echo "Uploading Photo..." . $phid;
?>
I'm guessing that the tmp file is being lost because of the redirect that happens when $f->auth("write") is called, but I don't know. Is there a way to preserve it? Is there any way to do this without saving the file to the server?
Answer: There is No way to directly upload a file to Flickr without saving it as an intermediate file.
I've moved on to using move_uploaded_file() followed by a flickr API call, and its working perfectly.
I've also managed to get it to play nice with the excellent Jquery Uploadify, which lets me send multiple files to it in one go.
I am working with the FaceBook API to upload photos, and the API requires a local file path. As far as I can tell they are handing the request off to CURL like such: upload=#localfilename
But my files don't reside locally, so I am trying to figure out if there is a way to make it work with a remote file....
I tried pointing it to a local file which just did 'echo file_get_contents('some_remote_image.jpg');'
but that didn't work.
Does anyone have any ideas?
Thanks!
You can however link to them eg
<img src="www.mydomain.com"/>
Is it not possible to cache the file on your server and then delete it after upload? I wrote a Flickr -> Facebook Photo Album app that does this very thing.
All right, well if you don't want to do that, you can do this:
Edit the file facebookapi_php5_restlib.php, tracing the photo upload calls down to the actual curl call, which is in:
private function post_upload_request($method, $params, $file, $server_addr = null)
Now the hacky part, instead of passing the filename for $file, pass in an array and then check if its an array in this function. If it is, extract the binary data from it and set it as one of the post parameters. Some curl parameters that you may need can be found here:
http://www.digimantra.com/technology/php/post-pictures-on-twitpic-api-using-php/