title: Allow Google Cloud Compute Engine Instance to write file to Google Storage Bucket - Python
body: <p>In my python server script which is running on a google cloud VM instance, it tries to save an image(jpeg) in the storage. But it throws following error.</p>
  
  <blockquote>
    <p>File "/home/thamindudj_16/server/object_detection/object_detector.py",
    line 109, in detect Hand
        new_img.save("slicedhand/{}#sliced_image{}.jpeg".format(threadname,
    i))   File</p>
    
    <p>"/home/thamindudj_16/.local/lib/python3.5/site-packages/PIL/Image.py",
    line 2004, in  save
        fp = builtins.open(filename, "w+b")</p>
    
    <p>OSError: [Errno 5] Input/output error: 'slicedhand/thread_1#sliced_image0.jpeg'</p>
  </blockquote>
  
  <p>All the files including python scripts are in a <strong>google storage bucket</strong> and have mounted to the VM instance <strong>using gcsfuse</strong>. App tries to save new image in the <strong>slicedhand</strong> folder. </p>
  
  <p>Python code snippet where image saving happen.</p>
  
  <pre><code>from PIL import Image
  
  ...
  ...
  
  i = 0
  new_img = Image.fromarray(bounding_box_img)      ## conversion to an image
  new_img.save("slicedhand/{}#sliced_image{}.jpeg".format(threadname, i))
  </code></pre>
  
  <p>I think may be the problem is with permission access. Doc says to use <code>--key_file</code>. But what is the key file I should use and where I can find that. I'm not clear whether this is the problem or something else.</p>
  
  <p>Any help would be appreciated.</p>