camerja icon indicating copy to clipboard operation
camerja copied to clipboard

Error: Directory

Open robinHurtado opened this issue 7 years ago • 2 comments

Hi I am getting this error: 14:30:57: [Error: Directory 'file:///data/user/0/host.exp.exponent/files/ExperienceData/%2540anonymous%252Fawesomeproject-61256c9a-b65e-45a2-b7ad-48b3fc298e0a/photos' could not be created.] Directory exists

I suppose that the promblem appears when it executes this: componentDidMount() { FileSystem.makeDirectoryAsync( FileSystem.documentDirectory + 'photos' ).catch(e => { console.log(e, 'Directory exists'); }); } So how can i fix this?

robinHurtado avatar Nov 03 '17 19:11 robinHurtado

I think adding the options object with intermediates set to true should resolve. See below :)

async componentDidMount() {
    try {
      await FileSystem.makeDirectoryAsync(
        `${FileSystem.documentDirectory}photos`,
        {
          intermediates: true,
        }
      )
    } catch (e) {
      console.log(e)
    }
  }

jswhisperer avatar Nov 27 '17 21:11 jswhisperer

@gregbenner that worked! thanks.

I had this error message on an iPhone device: could not be moved to ...

FYI: intermediates: true means create intermediate directories as required (link). Same as running mkdir -p on unix.

gianpaj avatar Dec 06 '17 09:12 gianpaj