I need to upload larger file on google stoarge.
Actually, what I'm doing is to create an URL in this way:
$url = $object->beginSignedUploadSession([
"options" => [
"x-goog-x-upload-content-type" => "$type",
"x-goog-content-type" => "$type",
]
]);
On frontend, I'm fetching this URL and make a PUT request with file
let type = files[i].type;
$.ajax({
type: "GET",
url: "/getUrl",
data: dataToPass,
success: function (json) {
var jsonParse = JSON.parse(json);
var url = jsonParse.url;
var formData = new FormData();
formData.append('file', files[i]);
var ajaxRequest = $.ajax({
type:'PUT',
url: url,
data: formData,
processData: false,
contentType: type,
cache: false,
xhr: function () {
myXhr = $.ajaxSettings.xhr();
if ( myXhr.upload) {
myXhr.upload.addEventListener('progress', thisIsAFunction, false);
}
return myXhr;
},
Upload seems works, but on my storage file is corrupted.
Actually the filetype is mp4, but storage save it as applicastion/octet-stream. Filesize is correct but file not working.