Exemplo 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;
 }
Exemplo 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;
 }
Exemplo n.º 3
0
 public function get()
 {
     if ($this->id) {
         $id = 0 + $this->id;
         $data = false;
         if ($id) {
             $data = $this->image()->get($id);
         }
         if ($data) {
             unset($data['user']);
             unset($data['src']);
             $data['labels'] = $this->image()->getLabels();
             return $this->status($data);
         } else {
             $this->error(18);
         }
     }
     $this->requiresLogin();
     $this->check_input(['ctx' => 1]);
     $upload_url = Bootstrap::$main->getRoot() . 'image';
     if ($this->_appengine) {
         $upload_url = CloudStorageTools::createUploadUrl($upload_url, []);
         $upload_url = $this->http2https($upload_url);
     } else {
         $upload_url = 'http://' . $_SERVER['HTTP_HOST'] . $upload_url;
     }
     $ret = array('success' => true, 'url' => $upload_url);
     if (isset($this->data['ctx'])) {
         if (!$this->data['ctx']) {
             $ctx = false;
         } else {
             if (is_string($this->data['ctx']) && substr($this->data['ctx'], 0, 1) == '{') {
                 $this->data['ctx'] = json_decode($this->data['ctx'], true);
             }
             if (is_string($this->data['ctx'])) {
                 $ctx = explode(',', $this->data['ctx']);
             } else {
                 $ctx = $this->data['ctx'];
                 if (!isset($ctx['event'])) {
                     $this->error(35);
                 }
                 if (!Tools::userHasAccessToEvent($ctx['event'])) {
                     $this->error(36);
                 }
             }
         }
         $ret['ctx'] = $ctx;
         Bootstrap::$main->session('image_ctx', $ctx);
     }
     return $ret;
 }
Exemplo n.º 4
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>
Exemplo n.º 5
0
 /**
  * Wrap a URL with its Cloud Storage uploader proxy
  *
  * @param string $url
  * @return string Wrapped URL
  */
 protected static function get_wrapped_url($url)
 {
     $options = ['gs_bucket_name' => get_option('appengine_uploads_bucket', ''), 'url_expiry_time_seconds' => 60 * 60 * 24];
     $wp_maxupsize = wp_max_upload_size();
     // set max_bytes_per_blob option only if max upload size is a positive int
     if (is_int($wp_maxupsize) && $wp_maxupsize > 0) {
         $options['max_bytes_per_blob'] = $wp_maxupsize;
     }
     // Setup internal authentication
     $sign_result = self::sign_auth_key(AUTH_KEY . get_current_user_id());
     $url = add_query_arg('gae_auth_user', get_current_user_id(), $url);
     $url = add_query_arg('gae_auth_key', $sign_result['key_name'], $url);
     $url = add_query_arg('gae_auth_signature', urlencode(base64_encode($sign_result['signature'])), $url);
     return CloudStorageTools::createUploadUrl($url, $options);
 }
Exemplo n.º 6
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');
Exemplo n.º 7
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>";
Exemplo 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);
 }
Exemplo n.º 9
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';
Exemplo n.º 10
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>
 public function testInvalidOptions()
 {
     $this->setExpectedException('\\InvalidArgumentException');
     $upload_url = CloudStorageTools::createUploadUrl('http://foo/bar', ['gs_bucket_name' => 'bucket', 'foo' => 'bar']);
 }
Exemplo n.º 12
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()
Exemplo n.º 13
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" />
Exemplo n.º 14
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;
}
Exemplo n.º 15
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;
Exemplo n.º 16
0
<?php

/// Copyright (c) 2004-2014, Needlworks / Tatter Network Foundation
/// All rights reserved. Licensed under the GPL.
/// See the GNU General Public License for more details. (/documents/LICENSE, /documents/COPYRIGHT)
$IV = array('POST' => array('target' => array('any', 'mandatory' => true)));
require ROOT . '/library/preprocessor.php';
require ROOT . '/library/error.php';
requireStrictRoute();
if (substr($_POST['target'], 0, 7) != '/owner/') {
    errorExit(404);
}
if (!defined('__TEXTCUBE_GAE__')) {
    Respond::PrintResult(array('error' => 0, 'url' => $_POST['target']));
    exit;
}
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = ['gs_bucket_name' => $_SERVER['blog_fs_bucket']];
$upload_url = CloudStorageTools::createUploadUrl($_POST['target'], $options);
Respond::PrintResult(array('error' => 0, 'url' => $upload_url));