/**
  * Get a list of objects from within a bucket
  * @param string $dir
  * @return array
  */
 public function getS3ObjectList($dir)
 {
     $c['delimiter'] = '/';
     if (!empty($dir) && $dir != '/') {
         $c['prefix'] = $dir;
     }
     $list = array();
     $cps = $this->driver->list_objects($this->bucket, $c);
     foreach ($cps->body->CommonPrefixes as $prefix) {
         if (!empty($prefix->Prefix) && $prefix->Prefix != $dir && $prefix->Prefix != '/') {
             $list[] = (string) $prefix->Prefix;
         }
     }
     $response = $this->driver->get_object_list($this->bucket, $c);
     foreach ($response as $file) {
         $list[] = $file;
     }
     return $list;
 }
 /**
  * Ensure that an uploaded file is unique
  *
  * @param string  $prefix
  * @param string  $fileName
  */
 protected function uniqueFile($prefix, $fileName)
 {
     // request a list of objects filtered by prefix
     $list = $this->s3->get_object_list($this->bucket, compact('prefix'));
     $path = join('/', array($prefix, $fileName));
     $i = 0;
     while (in_array($path, $list)) {
         $i++;
         $parts = explode('.', $fileName);
         $ext = array_pop($parts);
         $parts = array_diff($parts, array("copy{$i}", "copy" . ($i - 1)));
         $parts[] = "copy{$i}";
         $parts[] = $ext;
         $path = join('/', array($prefix, implode('.', $parts)));
     }
     if (isset($parts)) {
         $_FILES['newfile']['name'] = implode('.', $parts);
     }
 }
Ejemplo n.º 3
0
 $conn = mysql_connect(DB_HOST, DB_USERNAME, DB_PASSWORD) or die("Error:Couldn't connect to server");
 $db = mysql_select_db(DB_DBNAME, $conn) or die("Error:Couldn't select database");
 $query = "SELECT * FROM users WHERE authToken = '{$authToken}'";
 $result = mysql_query($query) or die("Error:Query Failed-1");
 if (mysql_num_rows($result) == 1) {
     $row = mysql_fetch_array($result);
     $username = $row["email"];
     $region = $row["region"];
 } else {
     die("Error: Incorrect authToken");
 }
 mysql_close($conn);
 $newFileName = md5($username . $deviceID) . "_";
 $s3 = new AmazonS3();
 $bucket = 'com.sanchitkarve.tb.usor';
 $response = $s3->get_object_list($bucket);
 $userFiles = array();
 $foundFiles = false;
 foreach ($response as $item) {
     if (startsWith($item, $newFileName)) {
         $userfiles[] = $item;
         $foundFiles = true;
     }
 }
 // create cloudfront link if possible
 $urls = "";
 //print_r($response);
 if ($foundFiles) {
     foreach ($userfiles as $uitem) {
         $link = $s3->get_object_url($bucket, $uitem, '10 minutes');
         // replace domain with cloudfront and put them in urls
 * Licensed under the Apache License, Version 2.0 (the "License"). You
 * may not use this file except in compliance with the License. A copy
 * of the License is located at
 *
 *       http://aws.amazon.com/apache2.0/
 *
 * or in the "license.txt" file accompanying this file. This file 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.
 */
error_reporting(E_ALL);
require_once 'sdk.class.php';
require_once 'include/book.inc.php';
// Create the S3 access object
$s3 = new AmazonS3();
if ($argc != 2) {
    exit("Usage: " . $argv[0] . " bucket name\n");
}
$bucket = $argv[1] == '-' ? BOOK_BUCKET : $argv[1];
// Retrieve array of al objects in bucket
$objects = $s3->get_object_list($bucket);
if ($objects) {
    foreach ($objects as $object) {
        print $object . "\n";
    }
} else {
    print "No objects found in " . $bucket . "\n";
}
exit(0);
Ejemplo n.º 5
0
    <input class="btn btn-success" style="clear: left; width: 100%; height: 32px; font-size: 13px;" type="submit" name="commit" value="Sign In" />
</form>
            </div>
            <? } ?>
          </li>
        </ul>
      </div>
    </div>
  </div>
</div>
        
        <?
        require_once './sdk.class.php';
        $s3 = new AmazonS3();
        $bucket = 'book-bucket-' . strtolower($s3->key);
        $fileList=$s3->get_object_list($bucket);
        
                  
  ?>
        <div id="showcase">
<!--            <div class="pull-right home">
                <a class="btn btn-small" href="#"><i class="icon-home pull-right "></i></a>
                </div>-->
            <div class="container fluid-grid">
                
                
                <?if(!isset($_SESSION['auth'])&&isset($_SESSION['msg'])){?>
                <div class="alert alert-error">
  <button type="button" class="close" data-dismiss="alert">×</button>
  <strong>Error!</strong>
  <? echo$_SESSION['msg'];?>