aws-amplify / amplify-js

A declarative JavaScript library for application development using cloud services.
https://docs.amplify.aws/lib/q/platform/js
Apache License 2.0
9.42k stars 2.12k forks source link

Error : [NoBucket: Missing bucket name while accessing object.] #13708

Closed tigerjiang closed 2 days ago

tigerjiang commented 1 month ago

Before opening, please confirm:

JavaScript Framework

React Native

Amplify APIs

Storage

Amplify Version

v6

Amplify Categories

storage

Backend

None

Environment information

This is the config file applicationConfig.json I have set the config via Amplify.config, bug when I invoke the method Amplify.getConfig, I can get the config info, It doesn't look correct {"Storage":{"S3":{}},"Auth":{"Cognito":{"userPoolId":"us-west-xxx","userPoolClientId":"xxx","identityPoolId":"us-west-xx","passwordFormat":{"requireLowercase":true,"requireNumbers":true,"requireUppercase":true,"requireSpecialCharacters":true,"minLength":8},"allowGuestAccess":true,"loginWith":{"email":true,"phone":false,"username":false},"userAttributes":{"email":{"required":true}}}}}

end when I upload a file It throws a exception, I print the config again before do uploading

{"Auth": {"Cognito": {"allowGuestAccess": true, "identityPoolId": "us-west-1:xxx", "loginWith": [Object], "passwordFormat": [Object], "userAttributes": [Object], "userPoolClientId": "4bk41ue2rd1iulqjiv5i46aatt", "userPoolId": "us-west-1_xxx"}}, "Storage": {"S3": {"bucket": undefined, "region": undefined}}}

Error : [NoBucket: Missing bucket name while accessing object.]

The bellow is the config content in applicationConfig.json

{
  "auth": {
    "user_pool_id": "us-west-1_xx",
    "aws_region": "us-west-1",
    "user_pool_client_id": "xxatt",
    "identity_pool_id": "us-west-1:bx17f71",
    "standard_required_attributes": [
      "email"
    ],
    "username_attributes": [
      "email"
    ],
    "user_verification_types": [
      "email"
    ],
    "password_policy": {
      "min_length": 8,
      "require_numbers": true,
      "require_lowercase": true,
      "require_uppercase": true,
      "require_symbols": true
    },
    "unauthenticated_identities_enabled": true
  },
  "storage": {
      "bucket": "xxx",
      "region": "xxx"
  },
  "version": "1"
}

the package.json is here { "name": "briskitgrill", "version": "0.0.1", "private": true, "license": "MIT", "scripts": { "android": "react-native run-android", "simulator": "mkdir -p ./ios/bundle;react-native bundle --entry-file ./index.js --dev false --bundle-output ./ios/bundle/main.jsbundle --assets-dest ./ios/release_ios --platform ios;react-native run-ios --simulator 'iPhone 15 Plus'", "ios": "mkdir -p ./ios/bundle;react-native bundle --entry-file ./index.js --dev false --bundle-output ./ios/bundle/main.jsbundle --assets-dest ./ios/release_ios --platform ios;react-native run-ios --device 'Mobphone'", "start": "react-native start", "test": "jest", "lint": "eslint --config .eslintrc.js --ext .js,.jsx src ", "fix": "eslint --config .eslintrc.js --ext .js,.jsx --fix src", "build": "./shell/build.sh", "setup": "./shell/install.sh", "update": "./shell/update.sh", "eject": "react-native eject", "i": "./shell/patch.sh", "postinstall": "patch-package", "clean": "react-native-clean-project" }, "pre-commit": [ "fix", "lint" ], "dependencies": { "@aws-amplify/pubsub": "^6.1.17", "@aws-amplify/react-native": "^1.1.4", "@native-html/iframe-plugin": "^2.6.0", "@react-native-async-storage/async-storage": "^1.24.0", "@react-native-clipboard/clipboard": "1.14.1", "@react-native-community/checkbox": "^0.5.17", "@react-native-community/cli": "^14.0.0", "@react-native-community/cli-platform-android": "^14.0.0", "@react-native-community/cli-platform-ios": "^14.0.0", "@react-native-community/netinfo": "^11.3.2", "@react-native-community/progress-view": "^1.4.2", "@react-native-community/segmented-control": "^2.2.2", "@react-native-community/slider": "^4.5.2", "@react-native-community/voice": "^1.1.9", "@react-native-firebase/app": "20.3.0", "@react-native-firebase/messaging": "20.3.0", "@react-native-masked-view/masked-view": "^0.3.1", "@react-native-picker/picker": "^2.7.7", "@react-navigation/bottom-tabs": "^6.6.1", "@react-navigation/drawer": "^6.7.2", "@react-navigation/material-top-tabs": "^6.6.14", "@react-navigation/native": "^6.1.8", "@react-navigation/stack": "^6.4.1", "@shopify/flash-list": "^1.7.0", "amazon-cognito-identity-js": "6.3.12", "aws-amplify": "^6.5.0", "date-fns": "^3.6.0", "deprecated-react-native-prop-types": "^5.0.0", "fbjs": "^3.0.5", "i18next": "^23.12.2", "link": "^2.1.1", "lottie-react-native": "6.7.2", "patch-package": "^8.0.0", "postinstall-postinstall": "^2.1.0", "react": "18.2.0", "react-i18next": "^15.0.0", "react-native": "^0.74.3", "react-native-ble-manager": "^11.5.5", "react-native-blob-util": "^0.19.11", "react-native-bootsplash": "^6.1.0", "react-native-camera": "^4.2.1", "react-native-check-version": "^1.1.1", "react-native-clean-project": "^4.0.3", "react-native-device-info": "^11.1.0", "react-native-easy-app": "^1.7.27", "react-native-fast-image": "^8.6.3", "react-native-fs": "^2.20.0", "react-native-geolocation-service": "^5.3.1", "react-native-gesture-handler": "2.18.1", "react-native-get-random-values": "^1.11.0", "react-native-image-crop-picker": "^0.41.2", "react-native-keyboard-aware-scroll-view": "^0.9.5", "react-native-linear-gradient": "^2.8.3", "react-native-localize": "^3.2.1", "react-native-logs": "^5.1.0", "react-native-network-info": "^5.2.1", "react-native-orientation-locker": "^1.7.0", "react-native-pager-view": "^6.3.3", "react-native-pdf": "6.7.5", "react-native-permissions": "^4.1.5", "react-native-phone-number-input": "^2.1.0", "react-native-pressable-opacity": "^1.0.10", "react-native-qrcode-scanner": "^1.5.5", "react-native-reanimated": "3.15.0", "react-native-render-html": "^6.3.4", "react-native-root-siblings": "^5.0.1", "react-native-root-toast": "3.6.0", "react-native-safe-area-context": "^4.10.8", "react-native-screens": "^3.34.0", "react-native-skeleton-placeholder": "^5.2.4", "react-native-snap-carousel": "^3.9.1", "react-native-sound": "^0.11.2", "react-native-svg": "^15.4.0", "react-native-svg-charts": "^5.4.0", "react-native-swiper": "^1.6.0", "react-native-tab-view": "^3.5.2", "react-native-url-polyfill": "^2.0.0", "react-native-vector-icons": "^10.1.0", "react-native-web": "^0.19.12", "react-native-webview": "13.10.5", "react-native-wifi-reborn": "^4.12.1", "react-native-youtube-iframe": "^2.3.0", "react-navigation": "^5.0.0", "react-redux": "^7.2.1", "redux": "^4.0.5", "redux-logger": "^3.0.6", "redux-promise-middleware": "^6.2.0", "redux-thunk": "^2.3.0", "save": "^2.9.0", "semver": "^7.6.3" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@eslint/compat": "^1.1.1", "@eslint/eslintrc": "^3.1.0", "@eslint/js": "^9.8.0", "@react-native/babel-preset": "^0.74.85", "@react-native/eslint-config": "0.74.85", "@react-native/metro-config": "^0.74.85", "@react-native/typescript-config": "0.74.85", "@testing-library/jest-native": "^5.4.2", "@testing-library/react-native": "^12.1.2", "@types/jest": "^29.4.0", "@types/lodash": "^4.17.7", "@types/node": "^18.14.1", "@types/react": "^18.2.6", "@types/react-native-vector-icons": "^6.4.18", "@types/react-test-renderer": "^18.0.0", "@typescript-eslint/eslint-plugin": "^7.17.0", "@typescript-eslint/parser": "^7.17.0", "babel-jest": "^29.6.3", "babel-plugin-inline-dotenv": "^1.7.0", "babel-plugin-module-resolver": "^5.0.0", "babel-plugin-root-import": "^6.6.0", "dotenv": "^16.3.1", "eslint": "^9.8.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-typescript": "^17.1.0", "eslint-import-resolver-typescript": "^3.6.1", "eslint-plugin-import": "^2.29.0", "eslint-plugin-jsx-a11y": "^6.8.0", "jest": "^29.2.1", "prettier": "2.8.8", "react-native-flipper": "^0.259.0", "react-test-renderer": "18.2.0", "reactotron-react-native": "^5.1.6", "reactotron-react-native-mmkv": "^0.2.6", "reactotron-react-query": "^1.0.4", "typescript": "5.1.3" }, "engines": { "node": ">=18" } }

Describe the bug

I am sure the storage info is correct, i cannot find any help info from amplify online doc. Error : [NoBucket: Missing bucket name while accessing object.]

Expected behavior

I want to upload a file to my backend s3 storage

Reproduction steps

  1. invoke Amplify.configure(AMPLIFY_CONFIG);
  2. upload a file through the method uploadData({ path: ${basePath}${file.name}, data: file,)

Code Snippet

// Put your code below this line.

Log output

``` // Put your logs below this line ```

aws-exports.js

No response

Manual configuration

No response

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

tigerjiang commented 1 month ago

Is there anyone can tell me what happen? Thanks

HuiSF commented 1 month ago

Hi @tigerjiang thanks for opening this issue.

Looking at your sample code:

Amplify.configure(AMPLIFY_CONFIG);

How do you map the amplifyconfiguration.json to the variable AMPLIFY_CONFIG? Have you double checked whether AMPLIFY_CONFIG has the correct configuration object?

ashika112 commented 1 month ago

@tigerjiang another thing i notice is that in your config.json for Storage, I see

 "storage": {
      "bucket": "xxx",
      "region": "xxx"
  },

I should be something like,

  "storage": {
    "aws_region": "us-east-1",
    "bucket_name": "XXXX",
 },
cwomack commented 2 days ago

Closing this issue as we have not heard back from you. If you are still experiencing this, please feel free to reply back and provide any information previously requested and we'd be happy to re-open the issue.

Thank you!