Skip to content

Commit

Permalink
Working version
Browse files Browse the repository at this point in the history
  • Loading branch information
gamalielhere committed Jun 2, 2020
1 parent 956c9e1 commit 6489374
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 34 deletions.
47 changes: 30 additions & 17 deletions src/dapps/ManageENS/ManageENS.vue
Original file line number Diff line number Diff line change
Expand Up @@ -813,38 +813,51 @@ export default {
}
},
async uploadFile(file) {
const content = await fetch('urls', {
method: 'POST',
body: {
method: 'getUploadUrl'
}
});
try {
fetch(content.signedUrl, {
method: 'PUT',
body: {
file
const content = await fetch(
'https://6szankrze5.execute-api.us-east-1.amazonaws.com/testing/ipfs',
{
headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({
method: 'getUploadUrl'
})
}
).then(response => {
return response.json();
});
fetch(content.body.signedUrl, {
method: 'POST',
body: file
}).then(response => {
if (!response.ok) {
Toast.responseHandler('Uploading file errored', Toast.ERROR);
return;
}
this.getHashFromFile(content.hashResponse);
this.getHashFromFile(content.body.hashResponse);
});
} catch (e) {
Toast.responseHandler(e, Toast.ERROR);
}
},
async getHashFromFile(hash) {
try {
const ipfsHash = await fetch('urls', {
method: 'POST',
body: {
method: 'uploadComplete',
hash: hash
const ipfsHash = await fetch(
'https://6szankrze5.execute-api.us-east-1.amazonaws.com/testing/ipfs',
{
headers: {
'Content-Type': 'application/json'
},
method: 'POST',
body: JSON.stringify({
method: 'uploadComplete',
hash: hash
})
}
).then(response => {
return response.json();
});
this.saveContentHash(ipfsHash);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ label {

.file-upload-container {
display: flex;
justify-content: flex-end;
justify-content: center;
position: relative;

input {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,6 @@
processed.
</div>
<div v-else>
<div class="file-upload-container">
<input
ref="zipInput"
type="file"
name="file"
placeholder="IPFS Hash"
@change="fileChange"
/>
<div class="submit-container">
<button @click.prevent="ipfsClick">
Upload your own website
</button>
</div>
</div>
<div class="form-container">
<form class="manage-form">
<div class="input-container">
Expand All @@ -273,6 +259,22 @@
</div>
</form>
</div>
<div class="file-upload-container">
<form enctype="multipart/form-data" novalidate>
<input
ref="zipInput"
type="file"
name="file"
accept=".zip"
@change="fileChange"
/>
<div class="submit-container">
<button @click.prevent="ipfsClick">
Upload your own website
</button>
</div>
</form>
</div>
</div>
</b-collapse>
<interface-bottom-text
Expand Down Expand Up @@ -457,12 +459,32 @@ export default {
},
methods: {
fileChange(e) {
this.processingIpfs = true;
// const formData = new FormData();
// const reader = new FileReader();
// const _self = this;
if (e.target.files[0].type !== 'application/zip') {
this.$refs.zipInput.value = '';
this.processingIpfs = false;
Toast.responseHandler('Please Upload a zip file!', Toast.WARN);
return;
}
this.processingIpfs = true;
// formData.append('file', e.target.files[0]);
// this.uploadFile(formData);
// console.log(e.target.files[0]);
this.uploadFile(e.target.files[0]);
// reader.onloadend = function (evt) {
// try {
// const binary = evt.target.result;
// const base64 = btoa(binary);
// _self.uploadFile(base64);
// } catch (e) {
// this.processingIpfs = false;
// Toast.responseHandler('Something went wrong', Toast.responseHandler);
// }
// };
// reader.readAsBinaryString(e.target.files[0]);
},
ipfsClick() {
const input = this.$refs.zipInput;
Expand Down
5 changes: 4 additions & 1 deletion vueConfig/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,8 @@ module.exports = [
'https://perkle-pub.esprezzo.io:8501',
'https://o382951.ingest.sentry.io:443',
'https://dispatch.pokt.network:443',
'https://service.gcp.pokt.network:443'
'https://service.gcp.pokt.network:443',
'https://6szankrze5.execute-api.us-east-1.amazonaws.com:443',
'https://mew-ipfs-bucket.s3.us-west-2.amazonaws.com:443',
'https://s3.us-west-2.amazonaws.com:443'
];

0 comments on commit 6489374

Please sign in to comment.