Method 1:
var dataUri = event.media.nativePath;
Titanium.Media.saveToPhotoGallery(dataUri);
xhr.onload = function(e) {
Ti.API.info('onload:- ' + JSON.stringify(this.responseText));
};
xhr.onerror = function(e) {
Ti.API.info('onerror:- ' + JSON.stringify(this.responseText));
};
xhr.onsendstream = function(e) {
Ti.API.info('math:- ' + Math.floor(e.progress * 100) + "%");
};
xhr.open('GET', 'https://www.googleapis.com/storage/v1/b/bucket_name/o?’);
xhr.onsendstream = function(e) {
Ti.API.info('math:- ' + Math.floor(e.progress * 100) + "%");
};
xhr.send({
file : dataUri,
key:'AIzaSyB558w5P9A1ftWfjSekdCJdWCI17bZwetM'
});
Result Found :
Response :- {
"error": {
"errors": [{
"domain": "usageLimits",
"reason": "ipRefererBlocked",
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.",
"extendedHelp": "https://cosole.developers.google.com"
}],
"code": 403,
"message": "There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed."
}
}
Method 2:
var dataUri = event.media.nativePath;
Titanium.Media.saveToPhotoGallery(dataUri);
xhr.onload = function(e) {
Ti.API.info('onload:- ' + JSON.stringify(this.responseText));
};
xhr.onerror = function(e) {
Ti.API.info('onerror:- ' + JSON.stringify(this.responseText));
};
xhr.onsendstream = function(e) {
Ti.API.info('math:- ' + Math.floor(e.progress * 100) + "%");
};
var REQUEST_URL = "https://www.googleapis.com/auth/devstorage.full_control";
xhr.open("GET", REQUEST_URL);
xhr.onsendstream = function(e) {
Ti.API.info('math:- ' + Math.floor(e.progress * 100) + "%");
};
xhr.send();
Result Found :
Response :- devstorage.full_control
Method 3:
var dataUri = event.media.nativePath;
Titanium.Media.saveToPhotoGallery(dataUri);
var xhr = Titanium.Network.createHTTPClient({
enableKeepAlive : false
});
xhr.send({
video : dataUri
});
xhr.setRequestHeader("enctype", "multipart/form-data");
xhr.setRequestHeader('Cache-Control', 'no-cache');
xhr.onerror = function(e) {
alert(e.error);
};
xhr.onload = function() {
var data = JSON.parse(this.responseText);
if (data.FILE)
alert('File: ' + data.FILE);
else
alert(this.responseText);
};
xhr.open('GET', ‘ipaddress/api_file/api_name’);
xhr.send();
Result Found :
Response :- {
"result": {
"errno": -4058,
"code": "ENOENT",
"syscall": "stat",
"path": "C:\Sites\Api\test\\file:\\\storage\\emulated\0\Pictures\\test-966434132.mp4"
},
"status": 2
}