423,688 Members | 1,894 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,688 IT Pros & Developers. It's quick & easy.

Issues when I upload multiple files to Alibaba Cloud OSS

P: 22
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(
ALIOSS::OSS_FILE_UPLOAD => $filepath,
'partSize' => 5242880,
);

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

//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) ;
var_dump($response);
}
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
Share this Question
Share on Google+
1 Reply


P: 51
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.