我想将图像上传到Microsoft Azure Blob存储。我创建了Microsoft Azure帐户和Blob存储。我提到了https://www.npmjs.com/package/angular-azure-blob-service
致电this.blob.upload(this.config);
时,我收到错误消息:
TypeError:无法读取未定义的属性“length” 文件:///android_asset/www/build/vendor.js
我的代码在ts
constructor(public navCtrl: NavController, public alertCtrl: AlertController,public blob: BlobService, public http: Http,private global: globalVariable) {
const Config: UploadParams = {
sas: 'https://aptestblob.blob.core.windows.net/?sv=2017-04-17&ss=bfqt&srt=sco&sp=rwdlacup&se=2017-12-06T03:00:34Z&st=2017-12-05T19:00:34Z&spr=https&sig=fG0RSjIlL3pqY86IPfWZzHpinoU5ziBtY0hSgH7BU9g%3D',
storageAccount: 'aptestblob',
containerName: 'aptestblob-container'
};
this.test.push(Config);
var that=this;
this.imagePath="file:///data/user/0/com.APEHS_ImageUpload/cache/tmp_IMG_20171003_1526141188888569.jpg";
this.imageBase="tmp_IMG_20171003_1526141188888569.jpg";
console.log('this.test '+JSON.stringify(this.test));
console.log('this.imagePath '+this.imagePath);
console.log('this.imageBase '+that.imageBase);
if (this.imagePath != "" && this.imagePath != null && this.imagePath != undefined && this.imagePath != 'undefined') {
const baseUrl = this.blob.generateBlobUrl(Config, that.imageBase);
console.log('baseUrl '+baseUrl);
var config = {
baseUrl: baseUrl,
sasToken: Config.sas,
file: this.imagePath,
complete: () => {
console.log('Transfer completed !');
},
error: () => {
console.log('Error !');
},
};
console.log('config '+JSON.stringify(config));
this.blob.upload(config);
}
}