posting dynamically to S3 - php

Good afternoon!
I am trying to replace my host with an S3 Amazon service for images. The website currently uploads images successfully using an uploader without problems. So the questions I have are about migrating from host to S3. Trust me I have read the Amazon support blogs and searched the net. But I can find no single, concise, or easy to understand technical advice--just a lot of Amazon jargon.
For info, at the moment the uploader does the two things you would expect it to do well:
1) it uploads the files to a target folder to the specified (Define) UPLOAD path(no problem)
2) it generates the image POSTS ready for processing (no problem).
It is a nice uploader with lots of goodies for image management so I don't want to replace it- I simply want to build a bridge from the outputs it creates (as above) into Amazon S3?.
So my specific questions are can anyone tell in simple terms how to:-
..enable users to Upload the images posted by my uploader to Amazon S3
..Allow users to get images back via their own dynamic page views.
Many thanks in anticipation
ps for info this is the uploader but im not sure that is needed bearing in mind it works as expected and produced the outputs above and I cannot replace it at this stage of the development process.
https://github.com/blueimp/jQuery-File-Upload

Related

Handling large file uploads and sending to API

I'm stuck wondering what the best solution is to handling large file uploads and sending them to a third-party API. Any pointers on what would be a good solution would be very welcome. Thank you in advance.
The end goal is to send video files to this API - https://docs.bunny.net/reference/manage-videos#video_uploadvideo. The complication is that the files are often large - up to 5GB in size.
I have an existing website built in PHP7 that runs on a LAMP setup on Amazon Lightsail and I want to add a feature for users to upload video files.
Currently I'm uploading the files directly to Amazon S3 using a pre-signed URL. This part is working fine.
But I need to send the files to the API mentioned above. This is where I get stuck!
I think there's two options to explore - (1) find a way to upload directly to the API and skip the S3 upload or (2) continue with uploading to S3 first and then transfer to the API. But I'm not sure if option 1 is even possible or how to do option 2!
With option 1, I'm wondering if there's a way to upload the files from the users directly to the API. If I do this using the regular HTML form upload, then the files are stored temporarily on my server before I can use cURL through PHP to transfer them to the API. This is really time consuming and feels very inefficient. But I don't know how else to send the files to the API without them first being on my server. Maybe there's an option here that I don't know about!
With option 2, I can already upload large files directly to S3 with pre-signed URLs and this process seems to run fine. But I don't know how I would then send the file from S3 to the API. I can use an S3 trigger on new files. But when I looked at Lambda, they have a tiny file size limit. Because my site is hosted on Lightsail, I noticed they have a container option. But I don't know if that can be used for this purpose and if so, how.
Basically, I'm not sure what solution is best, nor how to proceed with that. And maybe there's an option 3 that I'm not aware of!
I would welcome your input.
Many thanks in advance.

Adding image upload to html page (mysql backend)

Relatively new to web development here, but am trying to implement an image upload feature, the contents of which will be previewed to the person (administrator) uploading the image, and then stored in a database (and displayed to the end user on a different page).
I found a resource that uses a Imageshack API, and was a bit confused about what this is and how the person implemented the API to achieve the image upload. The code for this is here: http://www.sceditor.com/posts/how-to-upload-and-insert-an-image/
When I googled "Imageshack API," I kept running across something that said I need to request a key. What does this mean, and do I have to do it? Is this the easiest way to go about creating an image upload feature for my purposes?
Thank you all very much!
Imageshack API is for uploading image files to your account hosted at Imageshack.com. It seems that you want to upload image files to your own website and store such files on your own web servers (either in a cloud service such as AWS or your co-located/managed servers at some data centres). So, you probably do not want to use Imageshack.
As to how to upload image files using HTML & PHP, you may want to check out a short tutorial at:
www.w3schools.com/php/php_file_upload.asp
Also, by the way, storing image files into a database such as MySQL may not be a good idea -- image files should be stored as files. It is faster to access such image files on a web server than to access image contents stored in a database.

how to upload a image on imagemagick

I am using an API to add text to images which requires a URL to the image. I want to upload my images on imgur so that i have valid URL to use. I am using a php script with imgur as it is a part of an app. Since am using PHP I can easily use command line utilities. Please suggest some solution to this problem.
PS : Don't suggest using PHPGd or imagemagick to add text to image. They do not cater to my need. Also I tried google but most results assume upload to be upload on localhost/server while I want to upload on the net to have a valid URL to use. Also i dont think I have the technical know-how to use a VPS for this purpose.
If you're looking to use HTML/php to allow a user to upload a file to your server, here's a tutorial:
http://www.tizag.com/phpT/fileupload.php/
Please note that this process is unrelated to any image processing you might later perform with a tool such as ImageMagick or GD.
Edit: if you want to use php to make an image available on the Internet, Flickr is not a bad choice:
Uploading a photo with Flickr
ImageMagick is an image manipulation library. It has no functionality to upload files anywhere.
If you want to upload files, then you will need a service to upload them to (finding such a service is off-topic for SO, creating one is too broad for SO, finding hosting for one you create is off-topic for SO).
That service will provide some sort of API (although perhaps not one intended for automated access) which you will have to write a client to interact with.
If said service uses HTTP for uploads, then you should look at the cURL library.

Vimeo PHP Upload Directory

I have spent this best part of a week rattling my brain to get this working and I've just come to the conclusion that this is out of my scope. I know this is a rather large ask but I just can't figure it out. :(
Anyway, I am trying to upload some files in a directory on my webserver to Vimeo through a protected php script (I say protected because the script itself will not be accessible from the web) and have that script run via a cron job. The script will only upload to my account.
I have gotten as far as getting a consumer key and consumer secret from vimeo.
I have been attempting to use their documented API demo but that keeps requesting an oauth_token and oauth_token_secret, both of which I don't know how to obtain. I found it quite confusing and unsure if I could adapt it for my requirements. Instead, I googled and found this blog post about transfering files from youtube to vimeo - http://mclear.co.uk/2011/05/27/transfer-videos-from-youtube-to-vimeo/ - I thought I could use it as a building block but I've hit a dead end here also.
To explain the full scale of what I'm trying to achieve:
Video file is created on originating computer - Working
User adds ID3 tags to the file and drops it in a watched folder - Working
Local server sends the file via ftp to the webserver directory - Working
Php script reads the ID3 for the file and uploads it to vimeo - [ID3 Extractor working -Vimeo uploader not working]
Vimeo responds with upload location to script which then connects to our mysql server to add the record - Not working but straightforward to implement once uploader works
Thank you so much in advance for any help you can give.
Richard
I made some progress on this with the php "Transfer Youtube to Vimeo tool" I made
The download at the bottom of the article will get you uploading w/ PHP
The CLI tool is now available and comes with a video tutorial for how to use it.
Credit to #TomNomNom
Please don't contact me RE this I'm not supporting this code it was just hacked together :)

How to record voice files using PHP, FLASH

I am developing an application where I need to record voice(for those who does not have a webcam so they can use only microphone to record voice) or video(those who have a a webcam - like laptop or external) files and save them on server, thereafter save the file name and logged in users id on database for later access.
I know I need to use some sort of flash app for this. But is there any free one which could server this purpose or even if there are paid ones which could serve this purpose that would be great. I tried google but may be I was not being able to go after the proper term or something, I could not succeed finding a proper solution for this.
Please, help me out!
You can do that simply using jRecorder, a jQuery plugin. You don't even need a Flash Media Server or RED server. JRecorder is same as jPlayer, you can use jQuery and HTML to design your recorder and you don't even need Flash or Action script knowledge for this.
jRecorder uses 1 pix hidden swf file which manages all the recording / previewing and sending the file data (wav file) to a URL you defined (Where you can write code in PHP or Java to receive a POST file)
It is quite simple and tidy.
You can download this Plugin from:
http://www.sajithmr.me/jrecorder-jquery
I have same feature in our latest project, the client want to have video recording from webcam and the video appear in the user's profile page.
For the server, we implement the RED5 server. It need a Java virtual machine in your hosting. You can read the detail requirement and installation instruction in the website.
To handle recording, we develop our own flash application, because the client request a custom interface to match with the overall website interface. I don't know the detail, since we outsource it to a fellow flash developer. Maybe you can see follow this thread, the development of flash recording by JeroenW.
To play recorded video, you can use any flash video player that support playing rtmp video source. You cannot play the recorded flv file in RED5 directly, since the file lack of metadata required by the player. Serving the recorded file as rtmp is done by RED5.
In addition to red5 there is Adobe's own Flash Media server that allows you to record audio/video straight to the server.
Or if you feel geeky you might be able to put together your own solution for this using a socket connection to the server and decoding the stream yourself on the server side. You should be able capture the audio/video locally into memory and then feed the byte stream up to your own server application.
There are Open Source solutions but you will need an own server to run them.
There is no way to run these things from shared hosting except if your provider is really nice, and ready to install the necessary software.
I asked the same question a few weeks back, check out the answers.
This question when googling "How to record audio php" comes up first so here for anyone from the future.
A simple way to record audio with flash and save it with PHP:
https://github.com/clouddueling/SimpleRecorder
Record audio, post audio data to your choice of url.
You could try recordmp3online.com which has an SDK. The nice thing about this one, is that it doesn't need a third party server(ala Red5), and supports mobile devices that don't have flash installed.

Categories