Created
April 29, 2015 20:10
-
-
Save julien-duponchelle/6291bf6342afe2d3f146 to your computer and use it in GitHub Desktop.
Upload large file with Qt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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