How to create file paths inside bucket and upload specific files to it

Hi, I would like to know if there’s a way to specify even further paths when saving files with S3 Adapter. Let’s say I have a S3 instance and the bucket specified when configuring the adapter. I couldn’t understand whether or not setting bucketPrefix on the options would allow me to, for example, specify a folder inside another folder, in the s3, bucket. Would it do that ? Thanks in advance

I’ve never tried that to be honest but I think it should work.

1 Like

Well, I set the S3_BUCKET_PREFIX environemnt variable to parse_testing/ since this is the main folder of the project I’m trying to save my files. After that I tried a lot of different ways to add a new folder path to save specific files, succeeding with none. In this project I show what I’ve tried and why does not work. Most relevant tries were:

  1. Setting the file name with path of its specific folder:
    const filetext = await readFile()
    const parseFile = new Parse.File('/audios/new_audio.mp3', {base64: filetext})
    return parseFile.save({useMasterKey: true})

has no effect whatsoever, it just saves the file in the folder of the bucket prefix.

  1. This is the interesting try, when setting the absolute path within the bucket prefix folder, I receive an error from parse with an HTML message:
    const filetext = await readFile()
    const parseFile = new Parse.File('audios/new_audio.mp3', {base64: filetext}) 
    return parseFile.save({useMasterKey: true})

and I receive the following error:

{
	"code": 107,
	"error": "Received an error with invalid JSON from Parse: 
<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta 
charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n
<pre>Cannot POST /parse/files/audios/new_audio.mp3
</pre>\n</body>\n</html>\n"
}

So my questions are:

Is this a limitation from ParseFile ? Since when I put the path it ‘ignores’ it.
Why does this error occur ?
Should I create an issue to trying fixing this problem an be able to set paths when saving files ?

PS: Setting the whole path for saving specific files in S3_BUCKET_PREFIX works but it’s not the ideal solution, since I don’t want all my files to be saved there. For instance, setting parse_testing/audios/ as bucket prefix would work but would cause all my files to be saved there.

I believe that it is currently only possible to set a subfolder via S3 bucket prefix and not for each of the files.