2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +00:00

Allow upload of part images

- Requires API v6
This commit is contained in:
Oliver
2021-06-23 08:51:41 +10:00
parent 316391d5fb
commit 9e1305b1f0
2 changed files with 28 additions and 9 deletions

View File

@ -301,8 +301,26 @@ class InvenTreePart extends InvenTreeModel {
return img.isNotEmpty ? img : InvenTreeAPI.staticThumb;
}
void uploadImage(File image) async {
// TODO
Future<bool> uploadImage(File image) async {
// Upload file against this part
final http.StreamedResponse response = await InvenTreeAPI().uploadFile(
url,
image,
method: 'PATCH',
name: 'image',
);
if (response == null) {
print("uploadImage returned null at '${url}'");
return false;
}
if (response.statusCode != 200) {
print("uploadImage returned ${response.statusCode} at '${url}'");
return false;
}
return true;
}
// Return the "starred" status of this part