[BUGS ?] Workspace with FileStack credentials from another environment?

Hi,

We are working with images that are uploaded to FileStack using FileStack-js and FileStack-react with the credentials and security parameters to upload the files (apiKey, policy, signature), extracted from the workspace environment using the fileUploadInfo query:

{
  fileUploadInfo {
    policy
    signature
    apiKey
    path
  }
}

Then, when we make a mutation to our tables to incorporate the information from the image, we get the following error:

{
  "data": null,
  "errors": [
    {
      "message": "The argument is invalid",
      "locations": [
        {
          "line": 2,
          "column: 3
        }
      ],
      "path": [
        "fileCreate"
      ],
      "code": "InvalidArgumentError",
      "details": {
        "file": "File exists in another environment"
      }
    }
  ]
}

The value of fileId is obtained from the response given by the filestack-js client, and we try to make the mutation in 8base with:

mutation{
  fileCreate(data: {
    fileId: "<HANDLE OBTAINED>",
    filename: "<NAME>.jpg"
  }){
    go
    fileId
    downloadUrl
  }
}

At this point, we believe that the linked fileStack environment belongs to another workspace, since listing the existing images with the filesList query returns images that we have not uploaded in this project.

We need support about this to continue with the development. Thank you very much.
@alacret

Hi @leonellimap was this resolved?

I am also having this issue, getting the same error.

Any ideas @sebastian.scholl?

@jcollingj @sebastian.scholl
Yes, I found this solution: It was a missing property in the FileStack client settings. At first, I only used the parameters apiKey, policy and signature in the client initialization, and it did not work. But then I incorporated in the PickerOptions object the sub-object storeTo:

// FileStack client initialization

const clientOptions = {
   security: {
       policy: fileUploadInfo.policy,
       signature: fileUploadInfo.signature,
   },
};

const clientFileStack = filestack.init(
   fileUploadInfo.apiKey,
   clientOptions,
),

// Upload widget opening
const pickerOptions = {
   accept: 'image/jpeg',
   …
   storeTo: {path: fileUploadInfo.path}
 }
clientFileStack.picker(pickerOptions).open();

This way, I could have a correct connection to upload images.

2 Likes

Yes.

1 Like

Thank you @leonellimap! I ended up on the same path. Thank you for documenting the solution for future folks who land here.

@sebastian.scholl It could be worth pulling this into the documentation for working with filestack..

We’re revisiting this and seeing how we can better offer fileuploads and object storage.

What is the storeTo supposed to be?
I took the results from the query fileUploadInfo.path and added that property to the picker options like above, I got an error saying "invalid policy: provided path is not allowed: ...

Am I supposed to prepend a full URL to this? This is sanitized but my path looks something like this
"production/my8baseAPI/434rmsd43i5o3i4nd/"

Nevermind, I see what I was doing wrong. I just got the credentials directlty from the API explorer, instead of using the actual role I was on.