title: How to solve (OS Error: Operation not permitted, errno = 1) in flutter
body: <p>I want to save the image to my <strong>Download</strong> folder. I already add the permission but I still get the error like below.</p>
  <p>I have add the permission in AndroidManifest.xml  like these:</p>
  <pre><code>&lt;uses-permission android:name=&quot;android.permission.WRITE_EXTERNAL_STORAGE&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.READ_EXTERNAL_STORAGE&quot;/&gt;
      &lt;uses-permission android:name=&quot;android.permission.READ_INTERNAL_STORAGE&quot; /&gt;
  </code></pre>
  <p>I also have add <strong>android:requestLegacyExternalStorage=&quot;true&quot;</strong> in AndroidManifest.xml</p>
  <p>Beside that, I also have use the <strong>permission_handler: ^8.1.6</strong> to open the storage permission.</p>
  <pre><code> _requestPermission() async {
  Map&lt;Permission, PermissionStatus&gt; statuses = await [
    Permission.storage,
  ].request();
  
  final info = statuses[Permission.storage].toString();
  print(info);
  }
  </code></pre>
  <p>Here is the code for download the image. The package I use is <strong>downloads_path_provider: ^0.1.0</strong></p>
  <pre><code> Future&lt;File&gt; downloadImage(Uint8List data, String name) async {
      Directory tempDir = await DownloadsPathProvider.downloadsDirectory;
      String tempPath = tempDir.path;
      var filePath = tempPath + '/$name';
  
      var bytes = ByteData.view(data.buffer);
      final buffer = bytes.buffer;
  
      return File(filePath).writeAsBytes(
          buffer.asUint8List(data.offsetInBytes, data.lengthInBytes));
    }
  </code></pre>
  <p>Here is the error when I want to download the image.</p>
  <pre><code>E/flutter (26950): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: 
  FileSystemException: Cannot open file, path = '/storage/emulated/0/Download/image-2021-09-23 17:18:47.923358.jpg' 
  (OS Error: Operation not permitted, errno = 1)
  </code></pre>
  <p>Does anyone know how to solve this error?</p>