Update on Project – DirectLinkHosting

This is probably an extremely fast update but i did spend a lot of the night on this new project which is now up and running. As promised, the PHP behind the website is now available.
The function:
upload_GS($sourcefile, $targetfile, $secret_key, $authkey)
$sourcefile must be the REAL and long path to the file you want to upload.
$targetfile must be the path at which you want to upload the file.
$secret_key must be the secret to the access key (Google Storage Developers Section)
$authkey must be the access key (Google Storage Developers Section)
In practice:
The following script would upload the file (providing it exists) to the Google Storage Bucket. You can implement this next code in an IF statement, i will explain more about this later.
upload_GS(“/home/username/public_html/mymp3.mp3”, “/mymp3.mp3”, “SECRET”, “ACCESS_KEY”)
You will need to edit the PHP code and change where its actually uploading to because at the moment its set to upload to my storage bucket. You can very easily do this by editing all occurrences of “storage.directlinkhosting.cz.cc” with “commondatastorage.googleapis.com/BUCKETNAME” EXCEPT for the HOST header. This can be changed to “commondatastorage.googleapis.com”.

Embedded into a IF statement:
Seeing as the function that i created returns either TRUE or FALSE on success or failure, it is pretty simple to integrate into an IF statement.

if(!upload_GS(“/home/username/public_html/mymp3.mp3”, “/mymp3.mp3”, “SECRET”, “ACCESS_KEY”)) {
$error = “Critical Error!”;
} else {
// Insert into database? Do an action? Up to you!

The above PHP script will either insert data into a database or return an error. I hope you manage to integrate this into your scripts. If you want to make any modifications then feel free to and please do leave a comment. I am always up for improving my scripting skills.

There MAY be errors if you directly copy and paste the code because it is a slightly modified version of a script that is currently in use.


End Result: http://directlinkhosting.cz.cc/
Please excuse the really bad template which was taken from the glype proxy.. Designing is not my strongpoint.. The concept however works perfectly! 🙂


Attachment: http://blog.umarsalim.com/wp-content/uploads/2011/01/functions_GS.txt

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.