This commit is contained in:
78
docs/8.0/ayanova/docs/api-upload-routes.md
Normal file
78
docs/8.0/ayanova/docs/api-upload-routes.md
Normal file
@@ -0,0 +1,78 @@
|
||||
# API UPLOAD ROUTES
|
||||
|
||||
AyaNova has several API routes for uploading files.
|
||||
|
||||
These routes are all `POST` routes:
|
||||
|
||||
- `/api/v{version}/Attachment`
|
||||
- `/api/v{version}/ImportAyaNova7`
|
||||
- `/api/v{version}/Restore`
|
||||
|
||||
Upload routes are not testable from the API explorer.
|
||||
|
||||
Upload routes expect a form to be uploaded with file content disposition (multipart/form-data).
|
||||
|
||||
AyaNova will allow a maximum of 12gb per file upload for "Utility" routes such as restore and import routes.
|
||||
|
||||
User file routes such as attachments may have a smaller limit, see the User documentation section for those features for limit details.
|
||||
|
||||
Here is a sample minimal HTML form that works with AyaNova file routes:
|
||||
|
||||
```html
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title></title>
|
||||
<script src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||
crossorigin="anonymous"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
$("#upload").click(function (evt) {
|
||||
var fileUpload = $("#files").get(0);
|
||||
var files = fileUpload.files;
|
||||
var data = new FormData();
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
data.append(files[i].name, files[i]);
|
||||
}
|
||||
|
||||
//Attachment upload route requires further form data to designate
|
||||
//the object being attached to by it's type and id:
|
||||
//data.append('AttachToObjectType','2');
|
||||
//data.append('AttachToObjectId','200');
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "http://yourserver:7575/api/v8.0/Attachment",
|
||||
headers: {
|
||||
Authorization: "Bearer JWTTokenHere"
|
||||
},
|
||||
contentType: false,
|
||||
processData: false,
|
||||
data: data,
|
||||
success: function (message) {
|
||||
alert("upload successful!");
|
||||
console.log(message);
|
||||
},
|
||||
error: function (error) {
|
||||
console.log(error);
|
||||
alert("There was an error uploading files!");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<input type="file" id="files" name="files" multiple />
|
||||
<input type="button" id="upload" value="Upload file(s)" />
|
||||
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
Reference in New Issue
Block a user