JS implementation seven KN upload

Source: Internet
Author: User

Seven cows have JS uploaded documents and templates, but angry I blunt, write really rotten, the document is as follows
Https://developer.qiniu.com/kodo/sdk/1283/javascript

First of all to introduce three JS files,,, plupload.full.min.js qiniu.min.jsmain.js
These things are going to seven cow template file inside, the first one 好像 is plupload downloaded in the official website, plupload is a JS library

Then copy the following code, change the parameters inside, you can use the

//////////////////////////////////////It's my comment that's drawn like this.////////////////////////////////////varOption1= {    runtimes: ' HTML5,FLASH,HTML4 ',      //Upload mode, degenerate in turn//////////////////////////////////////This id-pick is the ID of the Select File button////////////////////////////////////    Browse_button: ' Id-pick ',         //Upload selected click button, Required    //During initialization, Uptoken,uptoken_url,uptoken_func must have one of the three parameters set    //Cut if more than one is provided, its priority is Uptoken > Uptoken_url > Uptoken_func    //Where Uptoken is to provide upload credentials directly, Uptoken_url is provided with an address to obtain the upload voucher, if required to customize the process of obtaining uptoken can be set Uptoken_func//////////////////////////////////////Get Uptoken way, three choose one, the second one is more reliable//How to get Uptoken to see a document of seven KN////////////////////////////////////    //Uptoken: ' <your upload token> ',//Uptoken is upload voucher, generated by other programs    Uptoken_url: ' https://xxx.com ',  //Ajax request Uptoken URL, highly recommended settings (server-side provided)    //Uptoken_func:function () {//The method is called when it needs to get Uptoken    / ///do something    //return uptoken;    // },    Get_new_uptoken: false,             //Set whether to retrieve new uptoken every time when uploading files    //Downtoken_url: '/downtoken ',    //Ajax request Downtoken URL, private space when used, JS-SDK will be to the address Post file key and domain, the server return JSON must contain the URL field, the URL value for the file's//////////////////////////////////////This is best changed to true, in order to prevent file name duplication////////////////////////////////////    Unique_names: true,              //The default false,key is the file name. If this option is turned on, JS-SDK will automatically generate a key (filename) for each file    //Save_key:true,//default false. If Sava_key is specified in the upload policy of the server generation Uptoken, the SDK will not handle any key in the frontend.//////////////////////////////////////This fill seven cow space domain name address, domain name + above generated filename =////////////////////////////////////    Domain: ' http://pwwfewfwfb.bkt.clouddn.com ',     //bucket domain name, used when downloading resources, required    Container: ' container ',             //Upload area Dom ID, default is Browser_button parent element    max_file_size: ' 30MB ',             //Max file volume limit    Flash_swf_url: ' path/of/plupload/moxie.swf ',  //introduce flash, relative path    max_retries: 3,                     //upload failed maximum retry attempts    DragDrop: true,                     //Turn on to drag to upload    drop_element: ' container ',          //Drag the ID of the upload AREA element, drag the file or folder to trigger the upload    chunk_size: ' 4MB ',                  //Block upload, the volume of each block//////////////////////////////////////If this is true, then the file will be automatically uploaded when it is selected.//If False, the selected file will not be uploaded and will need to be triggered next//So, Uploader.start (), can trigger upload////////////////////////////////////    Auto_start: false,                   //Select file to upload automatically, if you need to close the event trigger upload    Filters: {        max_file_size: ' 30MB ',        prevent_duplicates: true,        Mime_types:[{title: "Audio Files", Extensions: "MP3"}]},    //x_vars: {    //View custom variables    //' Time ': function (up,file) {    //var time = (new Date ()). GetTime ();    //Do something with ' time '    //return time;    //    },    //' Size ': function (up,file) {    //var size = file.size;    //do something with ' size '    //return size;    //    }    //},    Init: {        ' filesadded ': function(Up,Files{            Plupload. each(Files, function(file){                //files are added to the queue to handle related things            });        },        ' Beforeupload ': function(Up,File{            //Before uploading each file, deal with related things        },        ' uploadprogress ': function(Up,File{            //When uploading each file, deal with related things        },        ' fileuploaded ': function(Up,File,Info{            //Each file uploads successfully after processing related things        },        ' Error ': function(Up,Err,Errtip){            //When uploading an error, deal with related things        },        ' uploadcomplete ': function(){            after the queue file is processed, handle the related things        },        ' Key ': function(Up,File{            //If you want to personalize the key for each file on the front-end, you can configure the function            //The configuration must take effect at Unique_names:false,save_key:false            varKey= "";            //Do something with key here            returnKey}    }}varUploader= Qiniu.Uploader(Option1)

Plupload Documentation:
http://chaping.github.io/plupload/doc/

Document:
http://www.restran.net/2014/04/26/qiniu-js-file-upload/
https://glacierbo.github.io/2017/11/08/qiniu/
1190000008799185
Https://www.jianshu.com/p/9e694a505ad9
Https://www.jianshu.com/p/c03e939c0cc1
https://github.com/qiniu/python-sdk/blob/master/qiniu/auth.py

JS implementation seven KN upload

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.