ingest_random_image.py 564 B

123456789101112131415161718192021222324
  1. #/usr/bin/env python
  2. import uuid
  3. from generators import random_image, random_utf8_string
  4. host='http://localhost:5000' # Set this
  5. user='' # Set this
  6. password='' # Set this
  7. img_path = '/tmp'
  8. uid=str(uuid.uuid4())[-12:]
  9. with open(random_image(uid), 'rb') as f:
  10. rsp = requests.post(
  11. '{}/ldp'.format(host),
  12. auth=(user,password) if user or password else None,
  13. data = f.read(),
  14. )
  15. print('Response URL: {}'.format(rsp.url))
  16. print('Response code: {}'.format(rsp.status_code))
  17. print('Response message: {}'.format(rsp.text))