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!
}

Continue reading “Update on Project – DirectLinkHosting”