Closed danielj-genesis closed 4 months ago
@danielj-genesis Thank you for reaching out. It appears that there is a mismatch between the configuration files you provided in the ticket. Could you confirm that the one you're passing to the library contains the bucket information and that the bucket exists in your account? If so, could you check that the bucket information is present in the result of Amplify.getConfig()
after configuration?
@jimblanc Yes the one actually being used right now is the amplifyconfiguration.json and the bucket exists, same one that was being used previously.
The only difference is that on version 5 I was configuring this way which worked:
import { Amplify as AmplifySingleton /* Hub */ } from '@aws-amplify/core'
// import { onAuthUIStateChange, AuthState } from '@aws-amplify/ui-components'
import {
applyPolyfills,
// defineCustomElements
} from '@aws-amplify/ui-components/loader'
import { defineCustomElements } from '@aws-amplify/ui-components/dist/components/index'
// @ts-expect-error missing types
import awsmobile from '../aws_exports.ts'
import { UserModule } from '~/types'
import { Amplify } from 'aws-amplify'
Amplify.configure({
Storage: {
bucket: 'xxxxxxxxx-staging',
region: 'us-east-2' //REQUIRED - Amazon S3 bucket
}
})
export const install: UserModule = async (/* { app, router } */) => {
// app.config.globalProperties.$amplifyAuthRequiredFields = amplifyAuthRequiredFields
await AmplifySingleton.configure(awsmobile)
await applyPolyfills()
await defineCustomElements(window)
// const authMessageChannel = 'UI Auth'
// const noAuthMessage = 'user is undefined'
// app.config.compilerOptions.isCustomElement = tag => tag.startsWith('amplify-')
}
checking with Amplify.getConfig()
looks correct
@danielj-genesis Thanks for the clarification, just to be explicit the output of getConfig
contains the correct value for Storage.S3.bucket
@jimblanc I double checked and yes it's the same bucket name we've been using and I can go into s3 and confirm the bucket exists on same region with previous data. The old way I configured it I set the bucket explicitly but still same bucket.
@danielj-genesis Thank you for double checking. This error is thrown by the library when Storage.S3.bucket
is undefined in the configuration before the upload begins, and I am unable to reproduce the issue using uploadData
with Amplify JS 6.3.6. If you run getConfig()
immediately before you call uploadData
(in the same function), do you get the same result?
@jimblanc Okay interesting, I think this is the issue. By the time of upload the Storage config is gone:
I wonder what could cause part of the config to be removed?
@danielj-genesis Now we're on to something! Are you calling configure
in multiple places in your app?
@jimblanc Thank you! Okay I have this solved now. The reason was I was also using AmplifySingleton from before. Removing that makes it work.
@danielj-genesis Perfect, glad we got it sorted it!
Before opening, please confirm:
JavaScript Framework
Vue
Amplify APIs
Authentication, Storage
Amplify Version
v6
Amplify Categories
storage
Backend
Amplify CLI
Environment information
Describe the bug
When migrating to amplify 6.x.x from 5.3.6 and using the new setup:
and new upload:
I get this error:
Expected behavior
Before updating to 6.3.4 the upload worked normally with the s3 bucket amplify was setup with.
Reproduction steps
Install amplify 5.3.6 setup auth+storage
Update to amplify 6.3.4 Setup the new config Modify upload to new uploadData()
Code Snippet
Log output
aws-exports.js
Manual configuration
Not using manual anymore but the new amplifyconfiguration.json is the one I'm running Amplify.configure() with
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response