简体   繁体   中英

How to Store file (Resume) in windows azure mobile service using html and java script.?

I am making one website using html and java script am not using any server side technology . i am able to store text in windows azure mobile service. i want to store resume in my windows azure mobile service. can anyone know how to do this.?

I know we can do this by Blob storage but am getting example on windows 8 and windows phone.

i want to store resume by my website in windows azure mobile service.

You can always use storage services from Azure through ZuMo (Azure Mobile Services) but you don't save the blob directly, only you can create a url for the blob storage reference.

First, to use Windows Azure storage, you need to use the Node.js azure package in server scripts. For do that you need the first include in the script.

You need to create a Blob storage container, with createContainerIfNotExists function and upload the blob with createBlockBlobFromFile

More or less one fast example, it could be like that:

var azure = require('azure');
var qs = require('querystring');

function insert(item, user, request) {

    var host = 'ACCOUNT_NAME' + '.blob.core.windows.net';

    var blobService = azure.createBlobService('STORAGE_ACCOUNT_NAME', 'STORAGE_ACCOUNT_KEY', host);

    blobService.createContainerIfNotExists('CONTAINER_NAME'
        ,{publicAccessLevel : 'blob'} //remove this parameter is the access is not public
        ,function (error) {
          if (!error) {
            var sharedAccess = {
              AccessPolicy: {
                Permissions: 'rw', // Read and Write permissions
                Expiry: minutesFromNow(10)
              }  
            };

            var sasUrl = blobService.generateSharedAccessSignature('CONTAINER_NAME', 
                           'BLOB_NAME', sharedAccessPolicy);

            var sasQueryString = { 
              'sasUrl' : sasUrl.baseUrl + sasUrl.path + '?' + qs.stringify(sasUrl.queryString) 
            };                    

            request.respond(200, sasQueryString);
          }
        });
}

function minutesFromNow(minutes) {
  var date = new Date()
  date.setMinutes(date.getMinutes() + minutes);
  return date;
}

Finally in your JavaScript file, when the call to ZuMo returns, you should put the data into the url.

$.ajax({
  url: sasUrl, //the ZuMo parameter return.
  type: "PUT",
  data: $("#box").val(),
  headers: {
     "x-ms-blob-type": "BlockBlob"}
  })
.done(function (data) {
  $("#result").html(data);
  })
.fail(function (jqXHR, textStatus) {
  $("#result").html("Put failed: " + textStatus + " " + jqXHR.status);
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM