Dropbox get public url of the file after upload - php

Need to upload files to dropbox and get the public url of that file. I'am generating thumbnails and need to show that in my site. I should also show the original files to users without login to the dropbox site.
After uploading to dropbox I need to get the original file url which will be used by crocodoc api viewer.
I could able to upload the file and I am getting the metadata of that file. I created shared url and given that url that url img tag in html but seems returning as html instead of image.
I have gone through similar questions mentioned in SO but almost all are referring old documents.

I found this trick earlier and thought I'd share.
Go to: https://www.dropbox.com/home
Then, highlight your mouse over an item, click on share.
This will popup:
Simply change:
https://www.dropbox.com/s/io9oz94lgm2j2bb/loadingscreen.jpg?dl=0
to
https://dl.dropbox.com/s/io9oz94lgm2j2bb/loadingscreen.jpg
Replacing the www with dl, to get the direct, public url.

Related

Redirect direct image urls to image post or attachment page?

New :
I have a wallpaper website and I recently checked the server log of the files accessed and I saw that I am getting lots of traffic on the image files rather than the page of the website.
So I want to do is redirect example.com/sample-image.jpg to example.com/sample-image.html
I am using WordPress CMS and I tried one .htaccess code but it redirects all the images to the homepage of website :(
OLD:
When a user attempts to load an image directly into the browser (for example from Google Images), the browser normally opens just the bare image.
I'm trying to address the following situation:
1) User is browsing Google Images and finds an image. 2) Google Images offers the user to open the website where the image was found or just open the original image. 3) The user chooses the latter, therefore the ball is now on the webserver where the image is hosted. 4) htaccess detects a human operated browser trying to access directly to an image in /uploads/ folder. 5) htaccess redirects the user to single-attachment.php or post in which image include or attached.
Images/media it is post type. Try get_permalink($id_of_attachment); If you have url of image you can get id too. Example by get_post_thumbnail_id();

Secure files and display them as well

My question is about HTML and PHP.
This is my setup right now:
A website where user have accounts
A FTP server with pictures (currently none)
Files are currently saved on the website in the "PICTURES" folder (which is accessible by everybody who know the full URL)
So, I would like to know how I can display the images without storing them on the website (which will fix my URL problem).
My idea was to move the files on the FTP server, and when a users logon and request a page with those images, download them through a FTP connection, save them on the website, display the images, and remove them. Which would make them accessible only between the downloading time. But this solutions sounds REALLY bad to me.
You need always to have a place where your images are stored. But, if you don't want to give a user the chance to know where are stored, you can create a system which is used to show the images.
Think about this, if you want to download a file from Mega, you can't access to the URL where the file is stored, instead of that, the server itselfs calls a system who assign you a "key" and you can download the file only through that system using your "key".
You could use a system like "base64" so you can encode your image, and show it using it, or, you can use the "header" modifier so, you can display an image using a PHP code.
For example your image tag will be like:
<img src="processImage.php?id=01&user=10&key=123" />
So, your processImage will return a "tricky" image, actually not the image, but the code processed by PHP will be returned, like using "imagejpg()" function with the header "Content-Type:image/jpeg" and then the user will not know where the image is stored actually but the img will works actually.

How to output files from Dropbox with Dropbox PHP Core SDK

I want to output a file from Dropbox onto my website with Dropbox PHP Core SDK. To give an example, I upload an image to Dropbox. Now, how do I display that image to my website from Dropbox's servers. Keep in mind, I don't want to download this file from Dropbox and then display that image. Is it possible to display an image or another file directly from Dropbox using Dropbox PHP Core SDK?
EDIT:Would you mind being more clear on #1
How do I use the custom URL?
Can I do this: header("location: $url);
Is this how you use the custom url? Thanks!
Using the PHP Core SDK, the main way of accessing file content is using the getFile method, or for images where you don't need the full resolution, the getThumbnail method. However, these return the data directly, e.g., to save on your server and serve back to the user, so that doesn't suit your needs as described.
It sounds like you'd prefer the API to return a link to the image that you can use as the source for the images in the HTML of your page. The Dropbox API doesn't offer a method particularly well suited for that, but there are some non-ideal options:
1) You can use createTemporaryDirectLink to get a direct URL to the image. Note that these links expire after four hours though.
Using it would look like:
list($url, $expires) = $client->createTemporaryDirectLink("/default.png");
2) You can use createShareableLink to get a preview URL for the image. These links don't expire. Note that these don't link directly to the image data though, so you'd need to modify them as documented in this help article.
Using it would look like:
$url = $client->createShareableLink("/default.png");
Also, not that both of these are subject to bandwidth restrictions, per this help article.

How to show uploaded files in uploadcare?

I'm using uploadcare.com to store my images and files. I just started using it now. I was just wondering that how can i display the uploaded files in a web page. I looked through the documentation too. But didn't get anything to start with?
Is there anyone who have used it?
As per documentation, all images are available via CDN URL (this URL is returned by widget, it's up to you to save it). To add an image to your page just add an img tag:
<img src="http://www.ucarecdn.com/5651bbb6-c599-44bd-9c63-1db5e67db6ad/" />

Edit the mediawiki uploaded file name

In Mediawiki, we are uploading video using mediawiki api. Its uploading fine.It will be creating as a page like "File:Test.mp4". Now we want to edit the page title alone (Like "File:Test.mp4" to "File:Sample.mp4, but the video will be same). Kindly suggest any solution for editing.
To rename a MediaWiki page, you move it. This can be done with the API, if you don't want to move it manually:
/api.php?action=move&from=File:Test.mp4&to=File:Sample.mp4&token=xxxx
When you move a file page, the corresponding file will also be renamed. A redirect will be created from the old file page, so that both [[File:Test.mp4]] and [[File:Sample.mp4]] works throughout the wiki.

Categories