dsjklb0205 2012-01-10 20:16
浏览 24
已采纳

来自$ _POST和Amazon S3的文件

i have problem with amazon s3 service and a web service writed with php. This WS receive from $_POST a file base64encoded. I need to take this "string" and save to Amazon S3 bucket. I didn't find a right solution for do that, and after a week of work I'm looking for help here.

//$file = 'kdK9IWUAAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd'
$file = $_POST['some_file'];
$opt = array(
      'fileUpload' => base64_decode($file),
      'acl' => AmazonS3::ACL_PUBLIC
    );
$s3 = new AmazonS3(AWS_KEY, AWS_SECRET_KEY);
$response = $s3->create_object($bucket, $filename, $opt);

Thanks

  • 写回答

2条回答 默认 最新

  • doulu4316 2012-01-10 20:25
    关注

    Per the docs, fileUpload expects a URL or path, or an fopen resource.

    fileUpload - string|resource - Required; Conditional - The URL/path for the file to upload, or an open resource. Either this parameter or body is required.

    You should pass the decoded file data via the body parameter instead:

    body - string - Required; Conditional - The data to be stored in the object. Either this parameter or fileUpload must be specified.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)