Ejemplo n.º 1
0
 public function createUploadUrl()
 {
     //$action = $this->getActionDefault($options);
     $options = ['gs_bucket_name' => 'my_bucket'];
     $action = CloudStorageTools::createUploadUrl($_SERVER['REQUEST_URI'], $options);
     return $action;
 }
Ejemplo n.º 2
0
 /**
  * Generate an upload token and Google Cloud Storage upload URL.
  *
  * @param array $args
  * @return array
  */
 public function uploadToken($args)
 {
     /** @var ApisystemComponent $apisystemComponent */
     $apisystemComponent = MidasLoader::loadComponent('Apisystem');
     $data = $apisystemComponent->uploadGeneratetoken($args);
     $data['url'] = CloudStorageTools::createUploadUrl('/rest/googleappengine/upload/callback');
     return $data;
 }
Ejemplo n.º 3
0
 public function open($savePath, $sessionName)
 {
     $this->name = $sessionName;
     if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) {
         require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
         $this->savePath = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/sessions';
     } else {
         $this->savePath = $savePath;
         if (!is_dir($this->savePath)) {
             mkdir($this->savePath, 0777);
         }
     }
     return true;
 }
Ejemplo n.º 4
0
function doResumableUpload(Google_Client $client)
{
    // Drive service
    $driveService = new Google_Service_Drive($client);
    $gs_basepath = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName();
    $fileName = UPLOAD_FILENAME;
    // 82.52MB file
    $fileToUploadPath = $gs_basepath . "/{$fileName}";
    $uploadFilesize = filesize($fileToUploadPath);
    $options = array('gs' => array('enable_cache' => false, 'acl' => 'public-read'));
    $ctx = stream_context_create($options);
    if (($handle = fopen($fileToUploadPath, 'r', false, $ctx)) === false) {
        throw new Exception('fopen failed.');
    }
    $mimeType = CloudStorageTools::getContentType($handle);
    // prepare a drive file
    $file = new Google_Service_Drive_DriveFile();
    $file->setTitle($fileName);
    $file->setMimeType($mimeType);
    $file->setFileSize($uploadFilesize);
    // You can also set the parent folder:
    // @see https://developers.google.com/drive/v2/reference/files/insert
    $chunkSizeBytes = 256 * 1024 * 4 * 1;
    // upload in multiples of 256K (1M * n)
    // Call the API with the media upload, defer so it doesn't immediately return.
    $client->setDefer(true);
    $request = $driveService->files->insert($file);
    // Create a media file upload to represent our upload process.
    $media = new Google_Http_MediaFileUpload($client, $request, $mimeType, null, true, $chunkSizeBytes);
    // set the media filesize to the actual filesize.
    $media->setFileSize($uploadFilesize);
    // Upload the various chunks. $status will be false until the process is complete.
    $status = false;
    while (!$status && !feof($handle)) {
        $chunk = readChunk($handle, $chunkSizeBytes);
        $status = $media->nextChunk($chunk);
    }
    fclose($handle);
    // Reset to the client to execute requests immediately in the future.
    $client->setDefer(false);
    var_dump($status);
}
Ejemplo n.º 5
0
 /**
  * Create a URL for a target bucket and optional object.
  *
  * @visibleForTesting
  */
 public static function createObjectUrl($bucket, $object = null)
 {
     if (!isset($object)) {
         $object = "";
     }
     // Strip leading "/" for $object.
     if (StringUtil::startsWith($object, "/")) {
         $object = substr($object, 1);
     }
     $gs_filename = CloudStorageTools::getFilename($bucket, $object);
     return CloudStorageTools::getPublicUrl($gs_filename, true);
 }
Ejemplo n.º 6
0
<?php

session_start();
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'shweta'];
$upload_url = CloudStorageTools::createUploadUrl('/upload_handler.php', $options);
?>
<form action="<?php 
echo $upload_url;
?>
" enctype="multipart/form-data" method="post">
    Files to upload: <br>
   <input type="file" name="uploaded_file" size="40">
   <input type="submit" value="Upload">
</form>    
<form action="delete.php" enctype="multipart/form-data" method="post">
	<input type="submit" value="Delete Image">
</form>
<form action="comment.php" enctype="multipart/form-data" method="post">
	<input type="submit" value="Post Comment">
</form>
Ejemplo n.º 7
0
require_once '../../includes/initialize.php';
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
if (!$session->is_logged_in()) {
    redirect_to("login.php");
}
$max_file_size = 10485760;
// expressed in bytes
//     10240 =  10 KB
//    102400 = 100 KB
//   1048576 =   1 MB
//  10485760 =  10 MB
if (isset($_POST['submit'])) {
    $photo = new Photograph();
    $options = ['gs_bucket_name' => 'qiang2015'];
    $upload_url = CloudStorageTools::createUploadUrl('photo_upload.php', $options);
    $photo->caption = $_POST['caption'];
    $photo->attach_file($_FILES['file_upload']);
    if ($photo->save()) {
        // Success
        $session->message("Photograph uploaded successfully.");
        redirect_to('list_photos.php');
    } else {
        // Failure
        $message = join("<br />", $photo->errors);
    }
}
?>

<?php 
include_layout_template('admin_header.php');
Ejemplo n.º 8
0
 public function showImport()
 {
     $options = ['gs_bucket_name' => 'nder-firefly'];
     $upload_url = CloudStorageTools::createUploadUrl('/home/import', $options);
     return View::make('home.import')->with('url', $upload_url);
 }
Ejemplo n.º 9
0
$session_path = __DIR__ . '/../../media/sessions';
if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) {
    require_once 'google/appengine/api/users/User.php';
    require_once 'google/appengine/api/users/UserService.php';
    require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
    $mail = UserService::getCurrentUser()->getNickname();
    $session_token = md5($mail);
    $user = new userModel();
    $u = $user->find_one_by_email(strtolower($mail));
    if (isset($u['id'])) {
        Bootstrap::$main->session('user', $u);
        Bootstrap::$main->user = $u;
        Bootstrap::$main->session('time_delta', $u['delta']);
        echo '<h1><a href="/admin/">' . $u['firstname'] . ' ' . $u['lastname'] . '</a></h1>';
    }
    $session_path = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/sessions';
} else {
    echo "<h1>Witaj</h1>";
    @mkdir($session_path, 0755);
}
$session_file = "{$session_path}/{$session_token}.sess";
$session = file_exists($session_file) ? unserialize(file_get_contents($session_file)) : [];
$user = new userModel();
$users = $user->count();
$event = new eventModel();
$events = $event->count(['active' => 1, 'd_event_start' => ['>', Bootstrap::$main->now]]);
$guest = new guestModel();
$guests = $guest->join('event', 'events', 'id')->sum('persons', ['active' => 1, 'd_event_start' => ['>', Bootstrap::$main->now], 'd_payment' => ['>', 0], 'd_cancel' => null]);
echo '<div class="menu"><ul>';
if (!isset($menu)) {
    $menu = '';
Ejemplo n.º 10
0
function message_create($user_id_sender, $user_id_target)
{
    // upload_file
    /*
    * Adds record to table MESSAGE
    * Adds file metadata into table MESSAGE
    * Adds a record to table MESSAGE_DISTO for each target (recipient) // DEV_NOTE: currently only supports one recipient
    *
    * URL: /server?action=message_create
    */
    // get file meta data to insert into database and for response body
    $file_name = $_FILES['userfile']['name'];
    $file_type = $_FILES['userfile']['type'];
    $file_size = $_FILES['userfile']['size'];
    // get current timestamp and timezone
    $date = date_create();
    //$tz = $date -> getTimezone();
    $timestamp = date_format($date, 'Y-m-d H:i:s');
    //$timezone = $tz -> getName();
    // get error and temp info
    //$file_tmp_name = $_FILES['userfile']['tmp_name'];
    $file_error = $_FILES['userfile']['error'];
    $gs_name = $_FILES['userfile']['tmp_name'];
    // create user directory if it does not exist
    if (!file_exists('gs://androidsoundappproject.appspot.com/message/' . $user_id_sender)) {
        // create dir
        mkdir('gs://androidsoundappproject.appspot.com/message/' . $user_id_sender);
    }
    // save file
    $object_url = 'gs://androidsoundappproject.appspot.com/message/' . $user_id_sender . '/' . $file_name;
    //$options = stream_context_create(['gs'=>['acl'=>'public-read']]);
    $file = file_get_contents($gs_name);
    $options = array('gs' => array('acl' => 'public-read', 'Content-Type' => $_FILES['userfile']['type']));
    $ctx = stream_context_create($options);
    // place file into storage and give it public access
    if (true == file_put_contents($object_url, $file, 0, $ctx)) {
        //if (true == rename($_FILES['userfile']['tmp_name'], $object_url, $ctx)) {
        //if (move_uploaded_file($gs_name, $object_url)) { // may need to rename file with unique name
        // upload success
        $status = 201;
        header('Created', true, $status);
        $file_path = $user_id_sender . '/' . $file_name;
        $file_public_url = CloudStorageTools::getPublicUrl($object_url, false);
        // add file metadata to database table MESSAGE
        $dbh = dbConn();
        $sql = 'INSERT INTO MESSAGE (USER_ID_SENDER, FILE_NAME, FILE_TYPE, FILE_SIZE, FILE_PATH, DATE_SENT) 
                    VALUES (:USER_ID_SENDER, :FILE_NAME, :FILE_TYPE, :FILE_SIZE, :FILE_PATH, :DATE_SENT)';
        $qry = $dbh->prepare($sql);
        // parameter array
        $file_meta = array(':USER_ID_SENDER' => $user_id_sender, ':FILE_NAME' => $file_name, ':FILE_TYPE' => $file_type, ':FILE_SIZE' => $file_size, ':FILE_PATH' => $file_path, ':DATE_SENT' => $timestamp);
        $qry->execute($file_meta);
        $msg_id = $dbh->lastInsertId();
        // add recipients to database table MESSAGE_DISTRO // DEV_NOTE: add loop if we allow multiple recipients
        $sql = 'INSERT INTO MESSAGE_DISTRO (MSG_ID, USER_ID_SENDER, USER_ID_TARGET) 
                                VALUES (:MSG_ID, :USER_ID_SENDER, :USER_ID_TARGET)';
        $qry = $dbh->prepare($sql);
        // parameter array
        $distro = array(':MSG_ID' => $msg_id, ':USER_ID_SENDER' => $user_id_sender, ':USER_ID_TARGET' => $user_id_target);
        $qry->execute($distro);
        dbClose($dbh);
    } else {
        // upload fail
        $status = 501;
        header('Method Not Implemented', true, $status);
        $msg_id = null;
        //die('Could not rename.');
    }
    // build response array
    $response = array('MSG_ID' => $msg_id, 'USER_ID_SENDER' => $user_id_sender, 'FILE_NAME' => $file_name, 'FILE_TYPE' => $file_type, 'FILE_SIZE' => $file_size, 'FILE_PATH' => $file_path, 'FILE_PUBLIC_URL' => $file_public_url, 'DATE_SENT' => $timestamp, 'USER_ID_TARGET' => $user_id_target, 'tmp_name' => $gs_name, 'status' => $status, 'error' => $file_error);
    return $response;
    //return(sendResponse($response));
}
Ejemplo n.º 11
0
<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="css/style.css">
  <title>SoundWave: Client Actions</title>
</head>

<body>

<?php 
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'androidsoundappproject.appspot.com'];
//$upload_url = CloudStorageTools::createUploadUrl('/server', $options)
$upload_url = CloudStorageTools::createUploadUrl('/server?action=message_create', $options);
?>

<h1>SoundWave: Client Actions</h1>

<br>

<!-- 1. POST -->

<div id=main_post>
<table>
<tr>
  <td align="right" width="50px"><b>Action: </b></td>
  <td>user_create</td>
</tr><tr>
  <td align="right"><b>Method: </b></td>
Ejemplo n.º 12
0
<?php

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'rsvp-harmonli'];
$upload_url = CloudStorageTools::createUploadUrl('/submit', $options);
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <title>RSVP to Beth &amp; Ian's Wedding</title>

  <!-- Stylesheets -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Slab">
  <link rel="stylesheet" href="http://wedding.harmonli.com/fonts/mission-gothic/stylesheet.css">
  <link rel="stylesheet" href="http://wedding.harmonli.com/css/main.css">
  <link rel="stylesheet" href="/css/rsvp.css">
</head>
<body class="page-story">

  <?php 
include '_sidenav.php';
?>

  <form
      action="<?php 
echo $upload_url;
Ejemplo n.º 13
0
 public function image_path()
 {
     return CloudStorageTools::getImageServingUrl('gs://qiang2015/' . $this->filename, ['size' => 400, 'crop' => true]);
 }
Ejemplo n.º 14
0
<?php

use google\appengine\api\cloud_storage\CloudStorageTools;
require_once "c_transactions.php";
$db = new db_transactions();
// SQL statements
$sql_demographics = "INSERT INTO demographics (study_id, abs_date, facility_id, anc_id, psc_id, visit_count, " . "anc_visit_date, birth_date, residence, parity, gravida, gestational_period, lmp, edd," . " marital_status, hiv_status, initial_hiv_status, hiv_retest, woman_haart, haart_regimen, " . "counselling, hiv_status_partner, return_date, user_initial) ";
$sql_infant_registration = "INSERT INTO infant_registration(hei_id, d_study_id, birth_date, birth_weight, " . "sex, delivery_place, arv_prophylaxis, arv_pro_other, enrol_date, enrol_age, user_initial) ";
$sql_adherence = "INSERT INTO adherence(a_study_id, visit_date, haart_start_date, haart_regimen, art_effect, " . "self_art_adherence, self_ctx_adherence, cd4_taken, cd4_count, cd4_date, vl_taken, viral_load, " . "viral_date, who_stage, user_initial, next_visit_date) ";
$sql_variables = "INSERT INTO variables(v_study_id, visit_date, weight, height, hb_taken, hemoglobin, " . "hemoglobin_date, tb_status, preg_status, edd, fp_status, fp_method, disclosure, patner_tested, " . "user_initial, next_visit_date) ";
$sql_retention = "INSERT INTO retention (r_study_id, hiv_visit, next_visit, user_initial) ";
$sql_infant_diagnosis = "INSERT INTO infant_diagnosis(i_hei_id, visit_date, weight, height, " . "tb_contact, tb_ass_outcome, inf_milestones, imm_history, next_appointment, first_sample_collection, first_results_collected," . "first_results, second_sample_collection, second_results_collected, second_results, third_sample_collection, " . " third_results_collected, third_results, forth_sample_collection, forth_results_collected, forth_results," . "fifth_sample_collection, fifth_results_collected, fifth_results, sixth_sample_collection, sixth_results_collected," . "sixth_results, hei_outcome, exit_date, feeding_6wks, feeding_10wks, " . "feeding_14wks, feeding_9mths, feeding_12mths, feeding_15mths, feeding_18mths, " . "user_initial) ";
$bucket = CloudStorageTools::getDefaultGoogleStorageBucketName();
$root_path = 'gs://motivatestudy/';
$public_urls = [];
foreach ($_FILES['userfile']['name'] as $idx => $name) {
    $ext = strtolower(end(explode('.', $_FILES['userfile']['name'])));
    if ($_FILES['userfile']['type'][$idx] === 'text/csv') {
        echo "IT IS CSV";
        //$im = imagecreatefromjpeg($_FILES['userfile']['tmp_name'][$idx]);
        //imagefilter($im, IMG_FILTER_GRAYSCALE);
        //$grayscale = $root_path .  'gray/' . $name;
        //imagejpeg($im, $grayscale);
        $original = $root_path . 'csv/' . $name;
        move_uploaded_file($_FILES['userfile']['tmp_name'][$idx], $original);
        echo nl2br($original . 'idx ' . $idx);
        /* === */
        if ($csvfile = fopen("gs://motivatestudy/csv/variables.csv", 'r') !== FALSE) {
            echo nl2br("FILE READ SUCCSSFULY");
            echo nl2br($_FILES['userfile']['tmp_name']);
            if ($_REQUEST['form'] == "demographics") {
Ejemplo n.º 15
0
    }
    if (isset($_SERVER['HTTP_HOST'])) {
        echo '<h1>';
    }
    if ($migration->getCurrentVersion() == $version) {
        echo 'Database at version ' . $version . PHP_EOL;
    } else {
        $migration->migrate($version);
        echo 'Migrated succesfully to version ' . $migration->getCurrentVersion() . PHP_EOL;
    }
    if (isset($_SERVER['HTTP_HOST'])) {
        echo '</h1>';
    }
    if (isset($_SERVER['SERVER_SOFTWARE']) && strstr(strtolower($_SERVER['SERVER_SOFTWARE']), 'engine')) {
        require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
        $path = 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/sql';
        if (file_exists($path)) {
            foreach (scandir($path) as $file) {
                $f = $path . '/' . $file;
                echo 'Execute ' . $file . PHP_EOL;
                $conn->execute(file_get_contents($f));
            }
        }
    }
    if (isset($_REQUEST['sql']) && (!isset($google_user) || $google_user->getNickname() == '*****@*****.**')) {
        $r = $conn->execute($_REQUEST['sql']);
        print_r($r);
    }
    $conn->close();
} catch (Exception $e) {
    die($e->getMessage());
 public function url_stat($path, $flags)
 {
     if (!CloudStorageTools::parseFilename($path, $bucket, $object)) {
         if (($flags & STREAM_URL_STAT_QUIET) != 0) {
             trigger_error(sprintf("Invalid Google Cloud Storage path: %s", $path), E_USER_ERROR);
             return false;
         }
     }
     $client = new CloudStorageUrlStatClient($bucket, $object, $this->context, $flags);
     return $client->stat();
 }
 public function testParseFilenameWithBucketOnly()
 {
     $gs_filename = 'gs://bucket';
     $this->assertEquals(true, CloudStorageTools::parseFilename($gs_filename, $bucket, $object));
     $this->assertEquals('bucket', $bucket);
     $this->assertEquals(null, $object);
 }
Ejemplo n.º 18
0
 public static function log($app, $data = null)
 {
     if (Bootstrap::$main->appengine) {
         require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
     }
     $root = Bootstrap::$main->appengine ? 'gs://' . CloudStorageTools::getDefaultGoogleStorageBucketName() . '/' : __DIR__ . '/../../../media/';
     $file = $root . 'log/' . $app . '/' . date('Y') . '/' . sprintf('%02d', date('m')) . '/' . sprintf('%02d', date('d'));
     $d = date('Y-m-d H:i:s');
     $f = 0;
     while (file_exists("{$file}/{$d}:{$f}.txt")) {
         $f++;
     }
     $file = "{$file}/{$d}:{$f}.txt";
     $header = date('Y-m-d H:i:s');
     if (isset($_SERVER['REMOTE_ADDR'])) {
         $header .= ", IP:" . $_SERVER['REMOTE_ADDR'];
     }
     if (isset(Bootstrap::$main->user['email'])) {
         $header .= ", email: " . Bootstrap::$main->user['email'];
     }
     $header .= "\n";
     self::save(substr($file, strlen($root)), $header . print_r($data, 1) . "\n\n");
 }
Ejemplo n.º 19
0
    define('__TEXTCUBE_ATTACH_DIR__', 'gs://' . $_SERVER['blog_fs_bucket'] . '/attach');
    define('__TEXTCUBE_SKIN_STORAGE__', 'gs://' . $_SERVER['blog_fs_bucket'] . '/skin');
}
if (!array_key_exists('blog_fs_bucket', $_SERVER)) {
    syslog('Missing a blog_fs_bucket env variable in app.yaml');
    header("HTTP/1.0 404 Not Found");
    exit;
}
// Modify SCRIPT_NAME for other codes.
$_SERVER["SCRIPT_NAME"] = str_replace('gae.php', '', $_SERVER["SCRIPT_NAME"]);
// Handles $blogURL/attach/... for attachment files.
if (substr($_SERVER["REQUEST_URI"], 0, 8) == '/attach/') {
    $requestFilename = strtok(substr($_SERVER["REQUEST_URI"], 7), '?#');
    if (file_exists(__TEXTCUBE_ATTACH_DIR__ . $requestFilename)) {
        require 'library/function/file.php';
        $option = ['content_type' => getMIMEType('', $requestFilename)];
        CloudStorageTools::serve(__TEXTCUBE_ATTACH_DIR__ . $requestFilename, $option);
        exit;
    }
}
// Handles $blogURL/blog/skin/customize... for custom skin files.
if (substr($_SERVER["REQUEST_URI"], 0, 21) == '/skin/blog/customize/') {
    $requestFilename = strtok(substr($_SERVER["REQUEST_URI"], 5), '?#');
    if (file_exists(__TEXTCUBE_SKIN_STORAGE__ . $requestFilename)) {
        require 'library/function/file.php';
        $option = ['content_type' => getMIMEType('', $requestFilename)];
        CloudStorageTools::serve(__TEXTCUBE_SKIN_STORAGE__ . $requestFilename, $option);
        exit;
    }
}
require_once 'rewrite.php';
Ejemplo n.º 20
0
<?php

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'jonnytvguidenew.appspot.com'];
$upload_url = CloudStorageTools::createUploadUrl('/gcsprocess', $options);
$filename = $_FILES['uploaded_files']['name'];
$gs_name = $_FILES['uploaded_files']['tmp_name'];
move_uploaded_file($gs_name, 'gs://upload-app/' . $filename . '');
if (isset($_POST['Require']) && $_POST['Require'] === "UploadURL") {
    echo $upload_url;
}
 /**
  * Create a URL for a target bucket and optional object.
  *
  * @visibleForTesting
  */
 public static function createObjectUrl($bucket, $object = null)
 {
     // Strip leading "/" for $object
     if (isset($object) && $object[0] == "/") {
         $object_name = substr($object, 1);
     } else {
         $object_name = "";
     }
     $gs_filename = CloudStorageTools::getFilename($bucket, $object_name);
     return CloudStorageTools::getPublicUrl($gs_filename, true);
 }
Ejemplo n.º 22
0
 private function getAllowedBuckets()
 {
     static $allowed_buckets = null;
     if (!$allowed_buckets) {
         $allowed_buckets = explode(',', GAE_INCLUDE_GS_BUCKETS);
         $allowed_buckets = array_map('trim', $allowed_buckets);
         $allowed_buckets = array_filter($allowed_buckets);
         if (ini_get('google_app_engine.gcs_default_keyword')) {
             $allowed_buckets = array_map(function ($path) {
                 $parts = explode('/', $path);
                 if ($parts[0] == CloudStorageTools::GS_DEFAULT_BUCKET_KEYWORD) {
                     $parts[0] = CloudStorageTools::getDefaultGoogleStorageBucketName();
                 }
                 return implode('/', $parts);
             }, $allowed_buckets);
         }
     }
     return $allowed_buckets;
 }
Ejemplo n.º 23
0
<?php

include 'includes/header.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$uploadUrl = CloudStorageTools::createUploadUrl('/upload.php', $options);
?>

<div class="row ">
  <div class="panel panel-default col-sm-4 col-sm-offset-4">
    <form  action="<?php 
echo $uploadUrl;
?>
" method="post" enctype="multipart/form-data">
      <label class="control-label" for="csvFile">Upload Skiplist</label>
      <input accept=".csv" type="file" class="file" name="csvFile" accept="" required>
      <input type="submit" name="submit" class="form-btn" value="Upload Skiplist"><br>
    </form>
  </div>

</div>

<?php 
include 'includes/footer.php';
Ejemplo n.º 24
0
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
include_once 'creds.php';
// Get $bucket
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => $bucket];
$upload_url = CloudStorageTools::createUploadUrl('/process.php', $options);
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Cloud Vision API PHP Example</title>
</head>
<body>
    <form action="<?php 
echo $upload_url;
?>
" method="post" enctype="multipart/form-data">
    Your Photo: <input type="file" name="photo" size="25" />
    <input type="submit" name="submit" value="Submit" />
Ejemplo n.º 25
0
<?php

require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'androidsoundappproject.appspot.com'];
$upload_url = CloudStorageTools::createUploadUrl('/server', $options);
?>

<!DOCTYPE html>
<html>
<head>
<title>SoundWave</title>
</head>
<body>

<?php 
//if(isset($_POST['do-upload']) AND $_POST['do-upload'] === "yes") {
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //$yesupload = $_POST['do-upload'];
    //preg_match("/yes/", "".$yesupload."");
    $file_name = $_FILES['userfile']['name'];
    $gs_name = $_FILES['userfile']['tmp_name'];
    move_uploaded_file($gs_name, 'gs://androidsoundappproject.appspot.com/' . $file_name . '');
    // may need to rename file with unique name
    if ($_FILES['userfile']['error'] !== UPLOAD_ERR_OK) {
        die("Upload failed with error code " . $_FILES['userfile']['error']);
    }
    echo "<div>";
    //echo "File uploaded: ".$yesupload."</p>";
    echo "File name: " . $file_name . "</p>";
    echo "<pre>";
Ejemplo n.º 26
0
<!doctype html>
<html>
<body>

<?php 
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => 'androidsoundappproject.appspot.com'];
$upload_url = CloudStorageTools::createUploadUrl('/server?action=upload_file', $options);
?>

<!--?php echo $upload_url?-->
<?php 
//echo __dir__ . '\user_docs\\';
echo $upload_url . '?action=upload_file';
?>

<form action="<?php 
echo $upload_url;
?>
" enctype="multipart/form-data" method="post">
   <p>Files to upload: </p>
   <input type="file" name="userfile" >
   <input type="submit" value="Upload">
</form>

<br><br>

<?php 
include 'connection.php';
function tSpew()
Ejemplo n.º 27
0
 public static function set_default_bucket()
 {
     $current = get_option('appengine_uploads_bucket', false);
     if (!empty($current)) {
         return;
     }
     $default = CloudStorageTools::getDefaultGoogleStorageBucketName();
     update_option('appengine_uploads_bucket', $default);
 }
Ejemplo n.º 28
0
<?php

require_once __DIR__ . '/config.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
if (file_exists(MARKERS_JS)) {
    CloudStorageTools::serve(MARKERS_JS);
} else {
    header('Content-type: application/javascript');
}
Ejemplo n.º 29
0
use google\appengine\api\cloud_storage\CloudStorageTools;
$temp = explode(".", $thatfile);
$ext = end($temp);
if (in_array($ext, $valid_formats)) {
    if ($var6 < 200000) {
        echo "fil size is ";
        echo $var6;
        $fileName = 'gs://venkat123/' . $_FILES['uploaded_files']['name'];
        // echo $fileName."<br>";
        $options = array('gs' => array('acl' => 'public-read', 'Content-Type' => $_FILES['uploaded_files']['type']));
        $ctx = stream_context_create($options);
        if (false == rename($_FILES['uploaded_files']['tmp_name'], $fileName, $ctx)) {
            die('Could not rename.');
        }
        // $var2 =(new \ DateTime())->format('i:s');
        $object_public_url = CloudStorageTools::getPublicUrl($fileName, true);
        $var1 = date("Y-m-d H:i:s");
        $var2 = microtime(true);
        $var3 = $var2 - $var1;
        //   echo $var3;
        // echo $object_public_url."<br>";
        //  print $thisfile;
        // print $thatfile;
        // var_dump($_FILES);
        $db = new pdo('mysql:unix_socket=/cloudsql/ordinal-gear-93506:testdb;dbname=g1', 'root', '');
        $stmt1 = $db->prepare("select * from another where filename='{$thatfile}'");
        $stmt1->execute();
        $row = $stmt1->fetch();
        if ($row > 0) {
            echo "duplicate entry";
            // $db->exec("insert into users values('8975','200')");
Ejemplo n.º 30
0
 /**
  * Create a URL for a target bucket and optional object.
  *
  * @visibleForTesting
  */
 public static function createObjectUrl($bucket, $object = null)
 {
     $gs_filename = self::createGcsFilename($bucket, $object);
     return CloudStorageTools::getPublicUrl($gs_filename, true);
 }