-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.vue
78 lines (78 loc) · 1.84 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<template>
<div id="app">
<img alt="Vue logo" src="./assets/logo.png" />
<div v-if="img === ''">
<h3>Upload Image</h3>
<input type="file" accept="image/jpeg" @change="putS3Image($event)" />
</div>
<div style="margin:10px" v-if="result !== ''">
<strong>Objects found:</strong>
{{ result.join(', ') }}
</div>
<div v-if="img !== ''">
<img v-bind:src="img" />
</div>
<div>
<input type="button" v-if="img !== ''" value="Reset" @click="reset" />
</div>
<div id="amplify-signout">
<amplify-sign-out></amplify-sign-out>
</div>
</div>
</template>
<script>
import Storage from "@aws-amplify/storage";
import API, { graphqlOperation } from "@aws-amplify/api";
import { identifyLabels } from "./graphql/queries";
export default {
name: "App",
data() {
return {
result: "",
img: ""
};
},
methods: {
reset() {
this.result = "";
this.img = "";
},
putS3Image(event) {
const file = event.target.files[0];
Storage.put(file.name, file)
.then(async result => {
this.result = await this.identifyLabels(result.key);
this.img = await Storage.get(result.key);
})
.catch(err => console.log(err));
},
async identifyLabels(key) {
const inputObj = {
identifyLabels: { key }
};
const response = await API.graphql(
graphqlOperation(identifyLabels, { input: inputObj })
);
return response.data.identifyLabels;
}
}
};
</script>
<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
#amplify-signout {
max-width: 200px;
margin: 20px auto;
}
img {
max-width: 500px;
max-height: 325px;
}
</style>