Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

简单上传:上传成功后,地址可以访问但都是空白 #237

Open
ylnwqm opened this issue Aug 2, 2022 · 1 comment
Open

Comments

@ylnwqm
Copy link

ylnwqm commented Aug 2, 2022

使用sdk的简单上传

···php
composer show aliyuncs/oss-sdk-php

name : aliyuncs/oss-sdk-php
descrip. : Aliyun OSS SDK for PHP
keywords :
versions : * v2.4.3
php >=5.3

requires (dev)
phpunit/phpunit *
satooshi/php-coveralls *
···
第一行fopen 保证文件能够获取到是个资源

Ossclient.phpuploadFile打印$option 得到array结果,可以看到uploadFile参数是临时缓存目录资源,object为txt后缀的oss目录

image

同时在func generateHeaders 如果不拼接content-type 则会报MissingContentLength 错误

所以在其中添加

if (isset($options[self::OSS_CONTENT_LENGTH])) {
          $headers[self::OSS_CONTENT_LENGTH] = $options[self::OSS_CONTENT_LENGTH];
      }

此后可以上传成功,但是上传结果为空白,不仅仅是png,xlsx,doc等都为空白文件(上传之前确定文件可以打开,且有数据)

@Akuns
Copy link

Akuns commented Oct 14, 2024

我也遇到了一样的问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants