php - 使用预签名 URL 将对象上传到 AWS S3
问题描述
我想通过 dropzone 在 s3 存储桶中上传大文件。
我通过 Ajax 函数中的 RESTful api(预签名 URL PutObject)获得预签名 URL。
PHP ajax 函数代码:
$API_url = api_url;
$IdToken = $this->cognitoClient->getTokenIdCookie();
$curl = curl_init();
curl_setopt_array(
$curl,
array(
CURLOPT_URL => $API_url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: '.$IdToken
),
)
);
$response = curl_exec($curl);
curl_close($curl);
$response_data = json_decode($response);
$presigned_url= $response_data->url;
return $this->json(
array(
"presigned_url"=>$presigned_url
)
);
我想使用这个预签名的 URL 分段上传对象并跟踪其进度。
我已经查看了 javascript 中的“上传”功能,但我不知道如何将预签名的 url 与这个一起使用
解决方案
推荐阅读
- php - foreach loop and array_merge not matching correctly
- maven - 无法为 Intellij 中的 maven 项目执行目标 org.apache.maven.plugins:maven-surefire-plugin
- php - 如何使用 PHP 在浏览新选项卡中显示 pdf 而不是下载文件?
- django - 我有一个关于 django 模型的问题。我在 Visual Studio 代码中创建了一个 django 模型。当我输入 charfield 时,它建议我下面的代码
- python - 使用字符串和 int 对列表进行排序。仅排序 int Python
- python - 如何在 Python 中对以下代码进行矢量化而不加入两个数据帧
- python-3.x - jinja2 使用双引号
- python - 如何在 opencv 4.4.0 版上正确使用 cv2.findContours()?
- javascript - 单个头文件中当前页面的活动导航菜单突出显示
- flutter - Flutter Apple 登录包未返回所需的凭据