菜鸟教程小白 发表于 2022-12-11 19:58:34

ios - 文件 “IMG_00001.MOV” 无法打开,因为您无权查看它


                                            <p><p>当尝试将视频 url 转换为数据时出现错误:</p>

<pre><code>&#34;The file “IMG_00001.MOV” couldn’t be opened because you don’t have permission to view it.&#34;
</code></pre>

<p>这是我的代码:</p>

<pre><code>let videoUrl = Dictionary.object(forKey: &#34;videoUrl&#34;) as! String

do {
    let vidUrl = URL(fileURLWithPath: videoUrl)

    let videoData = try Data.init(contentsOf: vidUrl)
    videoMainData = videoData.base64EncodedString(options: Data.Base64EncodingOptions.endLineWithLineFeed)
} catch let error as NSError {
    print(error.localizedDescription)
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p><code>videoMainData?.write(to: vidUrl</code></p>

<p>尝试在之后添加此行。
                                  <code>videoMainData = videoData.base64EncodedString(options: Data.Base64EncodingOptions.endLineWithLineFeed)</code></p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 文件“IMG_00001.MOV” 无法打开,因为您无权查看它,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/44777649/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/44777649/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 文件 “IMG_00001.MOV” 无法打开,因为您无权查看它