Implement image uploads
This commit is contained in:
@@ -645,6 +645,32 @@ function oauthPost(endpoint, data, callback)
|
||||
xmlhttp.send(data.toString());
|
||||
}
|
||||
|
||||
// Make an object storage HTTP PUT request
|
||||
function objPut(url, data, progress, callback)
|
||||
{
|
||||
var xmlhttp = new XMLHttpRequest();
|
||||
xmlhttp.upload.addEventListener("progress", progress);
|
||||
xmlhttp.open("PUT", url, true);
|
||||
xmlhttp.setRequestHeader("Content-Type", "application/octet-stream");
|
||||
|
||||
xmlhttp.onreadystatechange = function()
|
||||
{
|
||||
if (xmlhttp.readyState != 4)
|
||||
return;
|
||||
|
||||
if (xmlhttp.status >= 400) {
|
||||
console.log("Error " + xmlhttp.status);
|
||||
console.log("PUT " + url);
|
||||
alert("An error occurred during file upload!");
|
||||
return;
|
||||
}
|
||||
|
||||
callback();
|
||||
};
|
||||
|
||||
xmlhttp.send(data);
|
||||
}
|
||||
|
||||
// Parse URL parameters
|
||||
function parseParams()
|
||||
{
|
||||
@@ -766,4 +792,4 @@ function translateKernel(slug, element)
|
||||
apiGet("/linode/kernels/" + slug, callback, null);
|
||||
}
|
||||
|
||||
export { settings, elements, regionNames, apiDelete, apiGet, apiPost, apiPut, md5, migrateETA, oauthPost, oauthScopes, parseParams, setupHeader, eventTitles, timeString, translateKernel };
|
||||
export { settings, elements, regionNames, apiDelete, apiGet, apiPost, apiPut, md5, migrateETA, oauthPost, oauthScopes, objPut, parseParams, setupHeader, eventTitles, timeString, translateKernel };
|
||||
|
||||
Reference in New Issue
Block a user