Issues when I upload multiple files to Alibaba Cloud OSS

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TimoHa
    New Member
    • Nov 2017
    • 22

    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 = '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?
  • IvanH
    New Member
    • Nov 2017
    • 51

    #2
    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.

    Comment

    Working...