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 = 'phpsdk13498493 94';
$object = 'Mining.the.Soc ial.Web-'.time().'.pdf' ; //English
$filepath = "D:\\Book\\Mini ng.the.Social.W eb.pdf"; //English
$options = array(
ALIOSS::OSS_FIL E_UPLOAD => $filepath,
'partSize' => 5242880,
);
$response = $obj->create_mpu_obj ect($bucket, $object,$option s);
_format($respon se);
}
//Upload the entire directory using multipart upload
function upload_by_dir($ obj){
$bucket = 'phpsdk13498493 94';
$dir = "D:\\alidata\\w ww\\logs\\aliyu n.com\\oss\\";
$recursive = false;
$response = $obj->create_mtu_obj ect_by_dir($buc ket,$dir,$recur sive);
var_dump($respo nse);
}
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?
Alibaba Cloud OSS provides two methods for uploading files.
//Upload a file through multipart upload
function upload_by_multi _part($obj){
$bucket = 'phpsdk13498493 94';
$object = 'Mining.the.Soc ial.Web-'.time().'.pdf' ; //English
$filepath = "D:\\Book\\Mini ng.the.Social.W eb.pdf"; //English
$options = array(
ALIOSS::OSS_FIL E_UPLOAD => $filepath,
'partSize' => 5242880,
);
$response = $obj->create_mpu_obj ect($bucket, $object,$option s);
_format($respon se);
}
//Upload the entire directory using multipart upload
function upload_by_dir($ obj){
$bucket = 'phpsdk13498493 94';
$dir = "D:\\alidata\\w ww\\logs\\aliyu n.com\\oss\\";
$recursive = false;
$response = $obj->create_mtu_obj ect_by_dir($buc ket,$dir,$recur sive);
var_dump($respo nse);
}
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?
Comment