Skip to content

Instantly share code, notes, and snippets.

@julien-duponchelle
Created April 29, 2015 20:10
Show Gist options
  • Save julien-duponchelle/6291bf6342afe2d3f146 to your computer and use it in GitHub Desktop.
Save julien-duponchelle/6291bf6342afe2d3f146 to your computer and use it in GitHub Desktop.
Upload large file with Qt
from PyQt5 import QtCore,QtNetwork
import sys
app = QtCore.QCoreApplication(sys.argv)
f = QtCore.QFile("test.image")
url = QtCore.QUrl("http://localhost:8001/v1/dynamips/vms/test.image")
request = QtNetwork.QNetworkRequest(url)
network_manager = QtNetwork.QNetworkAccessManager()
f.open(QtCore.QFile.ReadOnly)
response = network_manager.sendCustomRequest(request, "POST", f)
def callback(*argv, **kwargs):
status = response.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute)
print("Status", status)
sys.exit(0)
response.finished.connect(callback)
print("Exec")
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment