467,880 Members | 1,255 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,880 developers. It's quick & easy.

Issues when I upload multiple files to Alibaba Cloud OSS

When I upload multiple files to Alibaba Cloud OSS, do I upload files one by one or upload the entire directory at one go?
Alibaba Cloud OSS provides two methods for uploading files.
//Upload a file through multipart upload
function upload_by_multi_part($obj){
$bucket = 'phpsdk1349849394';
$object = 'Mining.the.Social.Web-'.time().'.pdf'; //English
$filepath = "D:\\Book\\Mining.the.Social.Web.pdf"; //English

$options = array(
'partSize' => 5242880,

$response = $obj->create_mpu_object($bucket, $object,$options);

//Upload the entire directory using multipart upload
function upload_by_dir($obj){
$bucket = 'phpsdk1349849394';
$dir = "D:\\alidata\\www\\logs\\aliyun.com\\oss\\";
$recursive = false;

$response = $obj->create_mtu_object_by_dir($bucket,$dir,$recursive) ;
Two approaches are available:
1. The first approach is uploading individual files a time. When the server received N files, it uploads the files in N times using the first function.
2. The second approach is transferring multiple files from a temporary directory to under a folder file and upload them all together using the second function. But I think it is too troublesome Ė creating a new folder to save the files to be uploaded, and then deleting the folder after the upload is done.
Which approach is better? If the second one is better, can I just create an exclusive temporary directory for the N files directly at the upload?
May 3 '18 #1
  • viewed: 1605
1 Reply
The possibility of upload failure has not been considered.
If the first approach is used, you can upload each file to be uploaded. If the second approach is used, when the upload fails, do you re-upload them all or are there other alternative solutions?
Honestly, I cannot see the advantage of the second approach. How is the second approach different from the first one, except in packaged uploading?
To sum up, the first approach sounds safer. The second approach involves too much to consider, without generating any overwhelming convenience. The loss outweighs the gain.
May 4 '18 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by JFB | last post: by
reply views Thread by deepaks85 | last post: by
reply views Thread by deepaks85 | last post: by
3 posts views Thread by djia002 | last post: by
reply views Thread by MrMoon | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.