some documentation fixes

This commit is contained in:
2018-08-06 23:33:03 +02:00
parent a0110a6c2a
commit 5a36b3a843
6 changed files with 29 additions and 16 deletions

View File

@@ -33,7 +33,8 @@ var UploadProgressBar = /** @class */ (function () {
UploadProgressBar.prototype.onFailure = function (response, error) {
this.uploadDiv.setAttribute('style', 'background: #821C40');
this.uploadDivJQ.html(this.file.name + '<br/>'
+ 'Upload failed after three tries!');
+ 'Upload failed after three tries!<br/>'
+ "Message: " + error);
};
return UploadProgressBar;
}());
@@ -161,14 +162,14 @@ var UploadWorker = /** @class */ (function () {
UploadWorker.prototype.upload = function (file) {
console.debug("Starting upload of " + file.name);
var formData = new FormData();
formData.append('file', file.file);
formData.append("name", file.name);
formData.append('file', file.file);
var that = this; // jquery changes the definiton of "this"
$.ajax({
type: 'POST',
url: apiEndpoint + "/file",
data: formData,
timeout: 7200000,
timeout: 21600000,
cache: false,
async: true,
crossDomain: false,
@@ -192,7 +193,6 @@ var UploadWorker = /** @class */ (function () {
error: function (xhr, status, error) {
console.log("status: " + status + " error: " + error);
if (that.tries === 3) {
alert("Upload failed: " + status);
file.onFailure(status, error);
setTimeout(function () { that.newFile(); }, 2000); // Try to continue
return; // Upload failed

View File

@@ -16,7 +16,7 @@ body{
font-family: 'Ubuntu', sans-serif;
margin: 0;
text-align: center; /* Center the header and body */
line-height: 140%;
line-height: 1.5em;
height: 100%;
overflow-x: hidden;
color: var(--text_color);
@@ -116,6 +116,7 @@ body{
/* Common elements */
h1, h2, h3, h4, h5, h6 {line-height: 1em;}
h3{border-bottom: 1px var(--accent_color_light_border) solid;} /* Differentiate it a bit, else it just looks like bold text */
hr{

View File

@@ -54,7 +54,8 @@ class UploadProgressBar implements FileUpload {
this.uploadDiv.setAttribute('style', 'background: #821C40')
this.uploadDivJQ.html(
this.file.name+'<br/>'
+ 'Upload failed after three tries!'
+ 'Upload failed after three tries!<br/>'
+ "Message: " + error
)
}
}

View File

@@ -68,8 +68,8 @@ class UploadWorker {
console.debug("Starting upload of " + file.name)
var formData = new FormData()
formData.append('file', file.file)
formData.append("name", file.name)
formData.append('file', file.file)
var that = this // jquery changes the definiton of "this"
@@ -77,7 +77,7 @@ class UploadWorker {
type: 'POST',
url: apiEndpoint+"/file",
data: formData,
timeout: 7200000, // 2 hours
timeout: 21600000, // 6 hours, to account for slow connections
cache: false,
async: true,
crossDomain: false,
@@ -103,7 +103,6 @@ class UploadWorker {
console.log("status: "+status+" error: "+error)
if (that.tries === 3) {
alert("Upload failed: " + status);
file.onFailure(status, error)
setTimeout(function(){that.newFile()}, 2000) // Try to continue

View File

@@ -55,6 +55,18 @@
relative to that URL.
</p>
<h2>Form value order</h2>
<p>
I recommend you put files at the end of every file upload form.
By doing this the pixeldrain server can respond to malformed
requests before the file upload finishes and this may save you a
lot of time and bandwidth when uploading large files. Make sure
your HTTP client has support for premature responses, pixeldrain
uses them a lot. If the server responds before your request is
finished it will always indicate an error and you may abort the
connection.
</p>
<h2>File Methods</h2>
{{template "api-file-post"}}
{{template "api-file-id-get"}}

View File

@@ -16,13 +16,6 @@
<td>Default</td>
<td>Description</td>
</tr>
<tr>
<td>file</td>
<td>true</td>
<td>5 000 000 000 Bytes</td>
<td>none</td>
<td>Multipart file to upload</td>
</tr>
<tr>
<td>name</td>
<td>false</td>
@@ -30,6 +23,13 @@
<td>Multipart file name</td>
<td>Name of the file to upload</td>
</tr>
<tr>
<td>file</td>
<td>true</td>
<td>5 000 000 000 Bytes</td>
<td>none</td>
<td>Multipart file to upload</td>
</tr>
</table>
<h3>Returns</h3>