title: Can't open remote FITS with astropy more than once
body: <p>I'm writing a package to handle astronomical FITS files. I want to allow files to be local or in the cloud. For local files I can <code>fits.getdata()</code> or <code>fits.open()</code> as many times as I want but on remote files, I have to close the file before I can open it again.</p>
  
  <p>This is an illustrative example of the problem:</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; file
  &lt;S3Boto3StorageFile: filename.fits.fz&gt;
  
  &gt;&gt;&gt; from astropy.io import fits                                                                                                                                                                             
  &gt;&gt;&gt; hdul = fits.open(file)                                                                                            
  &gt;&gt;&gt; hdul.info() 
  
  Filename: filename.fits.fz
  No.    Name      Ver    Type      Cards   Dimensions   Format
    0  PRIMARY       1 PrimaryHDU       8   ()      
    1  SCI           1 CompImageHDU    268   (3054, 2042)   float32   
    2  CAT           1 BinTableHDU    157   259R x 37C   [D, D, D, D, K, K, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, K, D, D]   
    3  BPM           1 CompImageHDU     10   (3054, 2042)   uint8  
  
  &gt;&gt;&gt; fits.getdata(file,header=True) 
  
  OSError: Empty or corrupt FITS file
  
  &gt;&gt;&gt; file.close()
  &gt;&gt;&gt; hdul = fits.open(file)
  &gt;&gt;&gt; hdul.info()
  
  Filename: filename.fits.fz
  No.    Name      Ver    Type      Cards   Dimensions   Format
    0  PRIMARY       1 PrimaryHDU       8   ()      
    1  SCI           1 CompImageHDU    268   (3054, 2042)   float32   
    2  CAT           1 BinTableHDU    157   259R x 37C   [D, D, D, D, K, K, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, D, K, D, D]   
    3  BPM           1 CompImageHDU     10   (3054, 2042)   uint8 
  </code></pre>
  
  <p>For remote files I need to do a <code>file.close()</code> before it can be opened again, whereas with local files I don't.</p>
  
  <p>Currently, I have to check if the input <code>file</code> is file-like (so I close it) or a Path or <code>str</code> (when I don't close it). It feels a bit hacky to have to do this check.</p>
  
  <p>If this is the intended behaviour, I was wondering why its different for local and remote files, or maybe even file-like objects and non-objects.</p>