def writeAndUploadCSV(data="", fieldnames=['name', 'category']):
  new_csvfile = io.StringIO()
  wr = csv.DictWriter(new_csvfile, fieldnames=fieldnames, quoting=csv.QUOTE_ALL)
  wr.writeheader()
  wr.writerow(data)
  buffer = io.BytesIO(new_csvfile.getvalue().encode())
  ts = datetime.datetime.now().timestamp()
  now = datetime.datetime.now()
  logs_bucket = os.environ.get('FPOIMG_AWS_BUCKET_LOGS', None)
  if logs_bucket:
    upload_file(
      buffer,
      logs_bucket,
      "queries/year={year}/month={month}/day={day}/hour={hour}/{ts}.csv".format(year=now.year, month=now.month, day=now.day, hour=now.hour, ts=ts)
    )