Allow images and detection upload for future data #56
@@ -437,7 +437,7 @@
|
||||
box.style.display = 'none'
|
||||
},
|
||||
submitData () {
|
||||
alert(this.newUid(12))
|
||||
this.uploadData(this.imageView.split(',')[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,28 @@ export default {
|
||||
uid.push(uidChars.charAt(Math.floor(Math.random() * ((i < 4) ? 26 : 36))))
|
||||
}
|
||||
return uid.join('')
|
||||
},
|
||||
uploadData (imagePayload) {
|
||||
/*****
|
||||
* This is the curl statement which works:
|
||||
* curl -k -T file.ext -u "LKBm3H6JdSaywyg:" -H 'X-Requested-With: XMLHttpRequest' https://nextcloud.azgeorgis.net/public.php/webdav/newFile.ext
|
||||
*
|
||||
* Also, curl --header "Content-Type: text/plain" --data-raw "simple_body" --trace-ascii website-data-raw.log "$website" might be an example of how to put in the jpeg data.
|
||||
*
|
||||
* Just need to work out:
|
||||
* 1) How that translates to a JS XHR
|
||||
* 2) Whether I've got another @#$% CORS issue with it
|
||||
* Answer: Bleep! Bleeeeeep! Bleep! Bleep! Bleep!....yes.
|
||||
*****/
|
||||
|
||||
var xhr = new XMLHttpRequest()
|
||||
var uploadUrl = `https://nextcloud.azgeorgis.net/public.php/webdav/${this.newUid(16)}.jpeg`
|
||||
xhr.open("POST", uploadUrl)
|
||||
xhr.setRequestHeader('Content-Type', 'image/jpeg')
|
||||
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
|
||||
xhr.setRequestHeader("Authorization", "Basic " + btoa("LKBm3H6JdSaywyg:"))
|
||||
|
||||
xhr.send(imagePayload)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user