I'd like to store my asset in the cloud. I thought Zend_Cloud_Storage may be the right library? For now they are saved locally using Zend_Cloud_StorageService_Adapter_Filesystem. Upload works so far.
What is the right way to send files from Zend_Cloud_StorageService_Adapter_Filesystem to the browser? I guess this is only possible by streaming them through php? If yes any code examples out there because I have problems getting it working with all the file header.
Using S3 I probably would make a redirect or directly link the files to the s3 bucket?
I'm pretty new to cloud storage so I really appreciate your help.
Kind regards, Manuel
The Zend Cloud services are fairly new and from my experience the documentation still needs a bit of work. Depending on the cloud service, you have either the choice of fetching your objects and delivering them to the user or in some cases you can give the user a direct URL to the asset (this largely depends on if you need to control access to the object).
To fetch an item programmatically, you should be able to get it to work with right header, for example:
$image = $storage->fetchItem("/my/remote/path/picture.jpg");
header("content-type: image/jpg");
echo file_get_contents($image);
In theory you can get the content type for the header from the metadata, but I'm not sure if it is consistent between adapters.
Linking directly depends on your Cloud. For the filesystem you should know the path to where your files are, so you can link from there if they are accessible. In Amazon, you can set the permissions to public when you upload the file - there is an example in the S3 doco here.
I'd recommend having a look at the Zend Service S3 doco, Zend Cloud is just a wrapper for it and in trying to be generic it looses a lot of functionality. if you work with it for any length of time I suspect you'll eventually end up doing calls straight to the service.
Good luck!
Related
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.
I think the question says it all. Since PHP5 we have a lot of methods for SQLite database handling. Now I have uploaded a SQLite file to my Google Drive Folder and granted read and write access for all to it. Is it now possible for me to connect to this database file from PHP with functions like:
$dbconn = sqlite_open($googleDriveLink); // or
$db = new SQLite3($googleDriveLink);
Read and write access in the context of google drive, means "read and write using their User Interface or APIs", on the other hand, PHP needs "Operating System's read and write access" to the file. Google is not exposing the file in a way that SqLite can handle it. The most best that perhaps in a tricky way, you can obtain is a download and an upload of it, but will collide with others and wont be useful.
You may want to educate yourself on Google Drive's API reference, specifically its section about Files.
You could pass it the download URL, as I assume that's what you mean by $googleDriveLink, but I don't think that's what you're looking for. Say, for example, privacy settings on the file are changed that don't allow anonymous downloads.
To take advantage of the Google Drive APIs in PHP, you'll need to leverage an HTTP client in your code that handles the communication, that or create a backend that your PHP code uses. It may be beneficial to read the Google API PHP Client Library's getting started document.
In whichever path you choose, you'll more than likely have to download the SQLite file to your PHP server and manipulate it locally, and then optionally update it on Google Drive.
Hope that helps.
I am totally new to Flex mobile developing.
In FlashBuilder for PHP, you need to specify local PHP server.
My answer is, how to change it to remote server?
Because, i have a hosting, and I need to put files there, to make it public.
You never need a local server per say. Have you tried to look at the files that Flash Builder creates for you (if I remember correctly, in this case it creates a service-config.xml file)? There should be one that mentions ServiceObjects and an endpoint of localhost. You can change this to your remote location.
I personally don't like the xml approach to creating services since it doesn't give me the flexibility I want in the code. I much prefer having it in the code using the ServiceObject class and specifying the endpoint and destination there and using a delegate pattern to call my services. Something for you to look into :)
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.
I'm starting a new project that involves users paying to see educational videos. These videos (FLV) are hosted with Amazon S3 while the site itself is hosted on a regular web host.
I've tried to read up on securing the S3 files, and can't find any good solution for this. I don't want my users to download the videos directly.
I read something about setting up a HTTP streaming server, but I'm not quite sure how a service like this works, and how to set it up.
Anybody with any experiences on how to solve this?
You might like to look at s2Member for Wordpress - it has Amazon s3 protected files built in, with the time lapse thing, plus protected pages/ etc that you can setup pretty easily.
I don't want my users to download the videos directly.
Get used to it.
Even with an RTMP streaming server, it's pretty easy to save the streams. You can add a load of obfuscation at the server and decoder to try to defeat the automated tools, but in the end what you have here is the unsolvable Copy Protection Problem.
There is no way to hide network path from end-user. However, you can go using expiring passwords that depend on time, user and content-section if Amazon allows you to use .htaccess files or PHP scripts.