Your search did not match any results.
File Uploader

Direct Upload to Azure

The FileUploader widget supports direct-upload to blob storages. This demo illustrates how to configure the uploadChunk option to upload a large file directly to Azure Blob Storage without using a user's web server. All APIs that implement access to Azure Blob Storage on the client are stored in the azure-file-system.js file.

To implement file upload logic, use the uploadChunk option to specify how to process a connection request to the storage.

Copy to CodePen
$(function() { var loadPanel = $("#load-panel").dxLoadPanel({ position: { of: "#file-uploader" } }).dxLoadPanel("instance"); $.ajax({ url: "", success: function(result) { var className = ? "show-widget" : "show-message"; $("#wrapper").addClass(className); loadPanel.hide(); } }); var endpointUrl = ""; gateway = new AzureGateway(endpointUrl, onRequestExecuted); $("#file-uploader").dxFileUploader({ chunkSize: 200000, maxFileSize: 1048576, uploadChunk: uploadChunk }); }); function uploadChunk(file, uploadInfo) { var deferred = null; if(uploadInfo.chunkIndex === 0) { deferred = gateway.getUploadAccessUrl( { uploadInfo.customData.accessUrl = accessUrl; }); } else { deferred = $.Deferred().resolve().promise(); } deferred = deferred.then(function() { return gateway.putBlock(uploadInfo.customData.accessUrl, uploadInfo.chunkIndex, uploadInfo.chunkBlob); }); if(uploadInfo.chunkIndex === uploadInfo.chunkCount - 1) { deferred = deferred.then(function() { return gateway.putBlockList(uploadInfo.customData.accessUrl, uploadInfo.chunkCount); }); } return deferred.promise(); } function onRequestExecuted(e) { $("<div>").addClass("request-info").append( createParameterInfoDiv("Method:", e.method), createParameterInfoDiv("Url path:", e.urlPath), createParameterInfoDiv("Query string:", e.queryString), $("<br>") ) .prependTo("#request-panel"); } function createParameterInfoDiv(name, value) { return $("<div>").addClass("parameter-info").append( $("<div>").addClass("parameter-name").text(name), $("<div>").addClass("parameter-value dx-theme-accent-as-text-color").text(value).attr("title", value) ); } var gateway = null;
<!DOCTYPE html> <html xmlns=""> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src=""></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="../azure-file-system.js"></script> <link rel="stylesheet" type="text/css" href="" /> <link rel="stylesheet" type="text/css" href="" /> <script src=""></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="data.js"></script> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="wrapper"> <div id="widget-area"> <div id="file-uploader"></div> <div id="request-panel"></div> </div> <div id="load-panel"></div> <div id="message-box"> To run the demo locally, specify your Azure storage account name, access key and container name in the web.config file. Refer to the <a href="" target="_blank"></a> to see the demo online. </div> </div> </div> </body> </html>
#widget-area { visibility: hidden; } #message-box { display: none; } .show-widget #widget-area { visibility: visible; } .show-message #widget-area { display: none; } .show-message #message-box { display: block; } #request-panel { min-width: 505px; height: 400px; overflow-x: hidden; overflow-y: auto; padding: 18px; margin-top: 40px; background-color: rgba(191, 191, 191, 0.15); } #request-panel .parameter-info { display: flex; } .request-info .parameter-name { flex: 0 0 100px; } .request-info .parameter-name, .request-info .parameter-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }