over 9 years ago
The upload method https://upgrade.odoo.com/database/v1/upload/ use this link to Upload a database dump Parameters
The request id and the private key are obtained using the create method For example see code below.
- import os
- import pycurl
- from urllib import urlencode
- from io import BytesIO
- import json
- UPLOAD_URL = "https://upgrade.odoo.com/database/v1/upload"
- DUMPFILE = "openchs.70.cdump"
- fields = dict([
- ('request', '10534'),
- ('key', 'Aw7pItGVKFuZ_FOR3U8VFQ=='),
- ])
- headers = {"Content-Type": "application/octet-stream"}
- postfields = urlencode(fields)
- c = pycurl.Curl()
- c.setopt(pycurl.URL, UPLOAD_URL+"?"+postfields)
- c.setopt(pycurl.POST, 1)
- filesize = os.path.getsize(DUMPFILE)
- c.setopt(pycurl.POSTFIELDSIZE, filesize)
- fp = open(DUMPFILE, 'rb')
- c.setopt(pycurl.READFUNCTION, fp.read)
- c.setopt(
- pycurl.HTTPHEADER,
- ['%s: %s' % (k, headers[k]) for k in headers])
- c.perform()
- c.close()
import os import pycurl from urllib import urlencode from io import BytesIO import json UPLOAD_URL = "https://upgrade.odoo.com/database/v1/upload" DUMPFILE = "openchs.70.cdump" fields = dict([ ('request', '10534'), ('key', 'Aw7pItGVKFuZ_FOR3U8VFQ=='), ]) headers = {"Content-Type": "application/octet-stream"} postfields = urlencode(fields) c = pycurl.Curl() c.setopt(pycurl.URL, UPLOAD_URL+"?"+postfields) c.setopt(pycurl.POST, 1) filesize = os.path.getsize(DUMPFILE) c.setopt(pycurl.POSTFIELDSIZE, filesize) fp = open(DUMPFILE, 'rb') c.setopt(pycurl.READFUNCTION, fp.read) c.setopt( pycurl.HTTPHEADER, ['%s: %s' % (k, headers[k]) for k in headers]) c.perform() c.close()
Note-With the help of above method we can uploads a database dump.
0 Comment(s)