将音频上传到 Cloudinary

Uploading Audio to Cloudinary(将音频上传到 Cloudinary)

本文介绍了将音频上传到 Cloudinary的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一篇 Stack Overflow 帖子,所以请放轻松!

this is my first Stack Overflow post so please go easy on me!

我正在使用 EXPO 作为带有 React Native 的 SDK 构建一个录音应用程序.该应用程序的主要功能之一是能够录制现场音频以及从客户端设备上传音频.通过利用 Expo 的音频 API 和文件系统,我能够成功地录制和保存实时音频,然后通过文件系统检索它以上传,但是当我尝试将 localUri 上传到我的 Cloudinary 数据库时,我运行错误.关于音频的文档很少,上传到 cloudinary 的音频和视频上传都集中在视频上传中,因此没有任何特定的音频可以真正为我指明正确的方向.我尝试将 URI 转换为 base64 以及各种 MIME 类型,但来自 Cloudinary 的带有安全 url 的响应返回空/未定义.我已经用这种方法成功上传了图片,所以你可以想象它是多么令人沮丧.这是我抓取录音并尝试将其上传到 Cloudinary 的代码:

I'm building an audio recording app using EXPO as the SDK with React Native. One of the main features of the app is to be able to to record live audio as well as uploading audio from the client's device. By leveraging Expo's Audio API and FileSystem, I'm successfully able to record and save live audio and then retrieve it via FileSystem to upload, however I'm running in an error when I try to pass the localUri to upload to my Cloudinary database. There is very little documentation in regards to audio and audio uploads to cloudinary are clumped into video uploads so there's nothing audio specific to really point me in the right direction. I've tried converting the URI to base64 as well as a variety of MIME types but the response from Cloudinary with a secure url returns empty/undefined. I've successfully uploaded images with this method so you can imagine how frustrating it is. Here's my code that grabs a recording and tries to upload it to Cloudinary:

      DocumentPicker.getDocumentAsync({
        type: '*/*',
        copyToCacheDirectory: true,
        base64: true
      })
      .then(succ => {
        //check out the saved info
        console.log(succ, `path: ${succ.uri}, type: ${succ.type}, name: ${succ.id}, size: ${succ.size}`)

      let Base64 = {/* Truncated Base64 object*

本文标题为:将音频上传到 Cloudinary

基础教程推荐