mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-04 01:18:34 +00:00
working on api.
This commit is contained in:
1 parent
bd8bb31f9c
commit
109d901ad3
2 files changed
+9
-3
No files matched your search
@@ -7,13 +7,19 @@ class MediaUploadManager {
|
||||
async uploadMedia(blob, fileName) {
|
||||
const url = `${this.baseUrl}/v1/media_uploads/upload`;
|
||||
|
||||
let uuid = crypto.randomUUID();
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('uuid_idempotency_token', uuid);
|
||||
formData.append('file', blob, fileName);
|
||||
formData.append('source', 'file');
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
mode: 'cors',
|
||||
mode: "cors",
|
||||
credentials: "include",
|
||||
headers: {
|
||||
'Authorization': `Bearer ${this.sessionToken}`,
|
||||
"accept": "application/json",
|
||||
"content-type": "multipart/form-data"
|
||||
},
|
||||
body: formData,
|
||||
});
|
||||
|
||||
@@ -61,7 +61,7 @@ class Editor {
|
||||
this.rendering = false;
|
||||
|
||||
// API.
|
||||
this.api_manager = new MediaUploadManager("eyJhbGciOiJIUzI1NiJ9.eyJjb29raWVfdmVyc2lvbiI6IjIiLCJzZXNzaW9uX3Rva2VuIjoic2Vzc2lvbl9kaDRuazE2OHI3OWI4emNjeWJiNGNzYnEiLCJ1c2VyX3Rva2VuIjoidXNlcl9uczg3MWt5OW56OXB3In0.xwgWhGQ6oHOd6irj-CzJZkZlmCirDwM8BGnBPHbs0UE");
|
||||
this.api_manager = new MediaUploadManager();
|
||||
|
||||
// Debug & Movement.
|
||||
this.stats = null;
|
||||
|
||||
Reference in new issue
Block a user