I have this function to upload file after the file is uploaded it returned uploaded path then
i pass it to tiny url this.tinyUrl.shorten(data.url).subscribe(sUrl => { shortUrl=sUrl;});
but the issue is sUrl
is returned with certain delay and further code gets executed i want till sUrl
is not returned the next code should not be executed.
handleUpload(file) {
let promise = new Promise((resolve, reject) => {
const contentType = file[0].type;
const bucket = new S3(
{
.....
}
);
.....
bucket.upload(params, (err, data)=> {
if (err) {
return false;
} else {
if (data.url) {
this.tinyUrl.shorten(data.url).subscribe(sUrl => {
shortUrl=sUrl;
});
}
resolve(this.FileUploadImage);
}
});
setTimeout(() => {
}, 4000);
});
}
Any solution Thanks