当前位置: 首页>>代码示例>>PHP>>正文


PHP S3::getHttpUploadPostParams方法代码示例

本文整理汇总了PHP中S3::getHttpUploadPostParams方法的典型用法代码示例。如果您正苦于以下问题:PHP S3::getHttpUploadPostParams方法的具体用法?PHP S3::getHttpUploadPostParams怎么用?PHP S3::getHttpUploadPostParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在S3的用法示例。


在下文中一共展示了S3::getHttpUploadPostParams方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateUploadPOSTParams

 public static function generateUploadPOSTParams($item, Zotero_StorageFileInfo $info, $useItemContentType = false)
 {
     if (strlen($info->hash) != 32) {
         throw new Exception("Invalid MD5 hash '{$info->md5}'");
     }
     if (!$item->isAttachment()) {
         throw new Exception("Item {$item->id} is not an attachment");
     }
     $linkMode = $item->attachmentLinkMode;
     switch ($linkMode) {
         // TODO: get these constants from somewhere
         case 0:
         case 1:
             break;
         default:
             throw new Exception("Attachment with link mode {$linkMode} cannot be uploaded");
     }
     $lifetime = 3600;
     $path = self::getPathPrefix($info->hash, $info->zip);
     $contentMD5 = '';
     for ($i = 0; $i < strlen($info->hash); $i += 2) {
         $contentMD5 .= chr(hexdec(substr($info->hash, $i, 2)));
     }
     $contentMD5 = base64_encode($contentMD5);
     if ($useItemContentType) {
         if ($info->zip) {
             $contentType = "application/octet-stream";
         } else {
             $contentType = $item->attachmentMIMEType;
         }
     } else {
         $contentType = $info->contentType;
     }
     $metaHeaders = array();
     $requestHeaders = array('Content-Type' => $contentType, 'Content-MD5' => $contentMD5);
     self::requireLibrary();
     S3::setAuth(Z_CONFIG::$S3_ACCESS_KEY, Z_CONFIG::$S3_SECRET_KEY);
     $params = S3::getHttpUploadPostParams(Z_CONFIG::$S3_BUCKET, $path, S3::ACL_PRIVATE, $lifetime, $info->size + 262144, 201, $metaHeaders, $requestHeaders, $info->filename);
     return $params;
 }
开发者ID:robinpaulson,项目名称:dataserver,代码行数:40,代码来源:S3.inc.php

示例2: exit

}
// Pointless without your keys!
if (awsAccessKey == 'change-this' || awsSecretKey == 'change-this') {
    exit("\nERROR: AWS access information required\n\nPlease edit the following lines in this file:\n\n" . "define('awsAccessKey', 'change-me');\ndefine('awsSecretKey', 'change-me');\n\n");
}
S3::setAuth(awsAccessKey, awsSecretKey);
$bucket = 'upload-bucket';
$path = 'myfiles/';
// Can be empty ''
$lifetime = 3600;
// Period for which the parameters are valid
$maxFileSize = 1024 * 1024 * 50;
// 50 MB
$metaHeaders = array('uid' => 123);
$requestHeaders = array('Content-Type' => 'application/octet-stream', 'Content-Disposition' => 'attachment; filename=${filename}');
$params = S3::getHttpUploadPostParams($bucket, $path, S3::ACL_PUBLIC_READ, $lifetime, $maxFileSize, 201, $metaHeaders, $requestHeaders, false);
$uploadURL = 'https://' . $bucket . '.s3.amazonaws.com/';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>S3 Form Upload</title>
</head>
<body>
    <form method="post" action="<?php 
echo $uploadURL;
?>
" enctype="multipart/form-data">
<?php 
foreach ($params as $p => $v) {
    echo "        <input type=\"hidden\" name=\"{$p}\" value=\"{$v}\" />\n";
开发者ID:ehazell,项目名称:AWBA,代码行数:31,代码来源:example-form.php


注:本文中的S3::getHttpUploadPostParams方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。