Upload a file in strapi and connect it to an Entry. (React Native and Strapi)

  Kiến thức lập trình

I’m using react native and I’m trying to upload an image to strapi and connect it an Entry. As the user completes there profile, I also want them to upload there profile picture. But when I upload the picture, It uploads to my server storage but it doesn’t connect to the user entry that I want.

What am I not doing right?

async function uploadImage(imgUri: string, jwt: string, refId: string, ref: string, source: string, field: string) {
  try {
    const uploading = await
      FileSystem.uploadAsync(
        `https://myurl.cloud/api/upload/?refId=${refId}&ref=${ref}&source=${source}&field=${field}`,
        `${imgUri}`,
        {
          headers: {
            'Authorization': `Bearer ${jwt}`
          },
          uploadType: FileSystem.FileSystemUploadType.MULTIPART,
          fieldName: "files",
        });
    return uploading
  } catch (error) {
    console.log(JSON.stringify(error, null,2))
    return null
  }
}

LEAVE A COMMENT