{"_id":"@aimeow/rn-oss","name":"@aimeow/rn-oss","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@aimeow/rn-oss","version":"0.0.1","description":"for alioss","main":"lib/commonjs/index","module":"lib/module/index","types":"lib/typescript/index.d.ts","react-native":"src/index","source":"src/index","scripts":{"test":"jest","typescript":"tsc --noEmit","lint":"eslint \"**/*.{js,ts,tsx}\"","prepare":"bob build","release":"dotenv release-it --","example":"yarn --cwd example","pods":"cd example && pod-install --quiet","bootstrap":"yarn example && yarn && yarn pods"},"keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/zym2525/react-native-oss.git"},"author":{"name":"zhengyiming","email":"540361168@qq.com","url":"https://github.com/zym2525"},"license":"MIT","bugs":{"url":"https://github.com/zym2525/react-native-oss/issues"},"homepage":"https://github.com/zym2525/react-native-oss#readme","publishConfig":{"registry":"https://registry.npmjs.org/"},"devDependencies":{"@commitlint/config-conventional":"^11.0.0","@react-native-community/eslint-config":"^2.0.0","@release-it/conventional-changelog":"^2.0.0","@types/jest":"^26.0.0","@types/lodash":"^4.14.171","@types/react":"^16.9.19","@types/react-native":"0.62.13","commitlint":"^11.0.0","eslint":"^7.2.0","eslint-config-prettier":"^7.0.0","eslint-plugin-prettier":"^3.1.3","husky":"^4.2.5","jest":"^26.0.1","lodash":"^4.17.21","pod-install":"^0.1.0","prettier":"^2.0.5","react":"16.13.1","react-native":"0.63.4","react-native-builder-bob":"^0.18.0","release-it":"^14.2.2","typescript":"^4.1.3"},"peerDependencies":{"react":"*","react-native":"*","lodash":"*"},"jest":{"preset":"react-native","modulePathIgnorePatterns":["<rootDir>/example/node_modules","<rootDir>/lib/"]},"husky":{"hooks":{"commit-msg":"commitlint -E HUSKY_GIT_PARAMS","pre-commit":"yarn lint && yarn typescript"}},"commitlint":{"extends":["@commitlint/config-conventional"]},"release-it":{"git":{"commitMessage":"chore: release ${version}","tagName":"v${version}"},"npm":{"publish":true},"github":{"release":true},"plugins":{"@release-it/conventional-changelog":{"preset":"angular"}}},"eslintConfig":{"root":true,"extends":["@react-native-community","prettier"],"rules":{"prettier/prettier":["error",{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false}]}},"eslintIgnore":["node_modules/","lib/"],"prettier":{"quoteProps":"consistent","singleQuote":true,"tabWidth":2,"trailingComma":"es5","useTabs":false},"react-native-builder-bob":{"source":"src","output":"lib","targets":["commonjs","module",["typescript",{"project":"tsconfig.build.json"}]]},"gitHead":"097da3537fb919f376fa336fe0165f0c066955f8","_id":"@aimeow/rn-oss@0.0.1","_nodeVersion":"18.17.0","_npmVersion":"9.6.7","dist":{"integrity":"sha512-UdY3kednkONuRxEroVjLdBaoI71pPE7qZdUpiVo20wwFS6BUGN/huQADqwA2ohanmFzu8QS5qbw8G42G3NVGfw==","shasum":"b2f1b094673e8e6f11073354da78fa38ae5baa18","tarball":"https://registry.npmjs.org/@aimeow/rn-oss/-/rn-oss-0.0.1.tgz","fileCount":46,"unpackedSize":191706,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC/2ujqOlwbXdyrl3L2ypTBXozrd5QlCOOIcDRe42qZhgIhAJq7Gb7RpEgnMyE2rofwRm5KMAUgqtwaRn6IFfF1/cT7"}]},"_npmUser":{"name":"aimeow","email":"a18814888787@gmail.com"},"directories":{},"maintainers":[{"name":"aimeow","email":"a18814888787@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/rn-oss_0.0.1_1695632708100_0.634007110097957"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-25T09:05:08.025Z","0.0.1":"2023-09-25T09:05:08.362Z","modified":"2023-09-25T09:05:08.656Z"},"maintainers":[{"name":"aimeow","email":"a18814888787@gmail.com"}],"description":"for alioss","homepage":"https://github.com/zym2525/react-native-oss#readme","keywords":["react-native","ios","android"],"repository":{"type":"git","url":"git+https://github.com/zym2525/react-native-oss.git"},"author":{"name":"zhengyiming","email":"540361168@qq.com","url":"https://github.com/zym2525"},"bugs":{"url":"https://github.com/zym2525/react-native-oss/issues"},"license":"MIT","readme":"# rn-aliyun-oss\n\nfor alioss\n\n## Installation\n没有上传到npm服务器上，只能在package.json 指定代码路径\n```sh\n\"rn-aliyun-oss\":\"git@github.com/sunny635533/rn-aliyun-oss.git\"\n```\n\n## Usage\n\n```js\nimport { NativeModules } from 'react-native';\nimport { Tools } from '../utils/All';\nimport md5 from 'js-md5';\n\n// const OssModule = NativeModules.Oss;\n\nimport AliyunOss from \"rn-aliyun-oss\";\n\nconst defaultConfig = {\n  configuration: {\n    maxRetryCount: 1,//请求最大次数\n    timeoutIntervalForRequest: 30,//请求超时时间，单位秒\n    timeoutIntervalForResource: 24 * 60 * 60,//传输最大时间，单位秒\n  },\n  accessKey: 'xxxxxxx',\n  secretKey: 'xxxxxxxxxxxxxxxxxxxxx',\n  bucketName: 'ibooming',\n  endPoint: \"https://xxxx.aliyuncs.com\",\n};\n\n/**\n * 阿里云的服务的文件处理\n */\nexport default class OssBusiness {\n  config = defaultConfig;\n\n  constructor(props) {\n    this.initWithAppKey();\n  }\n\n  initWithAppKey() {\n    AliyunOss.initWithAppKey(this.config.accessKey, this.config.secretKey, this.config.endPoint, this.config.configuration);\n  }\n\n  getOssFileUrl(path) {\n    return \"https://oss.xxxx.yun/\" + path;\n  }\n\n  createOssPath(type = 0, filePath, ossBasePath = \"app/\") {\n    const nowDate = Tools.getCurrentTimeStr(\"yyyyMMDD\");\n    let dirPath = \"\"\n    if (type == 0) {\n      dirPath = \"images/community/\";\n    } else {\n      dirPath = \"videos/community/\";\n    }\n    let fileType = \"\";\n    const lastIndex = filePath.lastIndexOf(\".\");\n    if (lastIndex > -1) {\n      fileType = filePath.substring(lastIndex);\n    }\n    //文件名称，用文件完整路径+时间戳\n    const dateStr = new Date().getTime();\n    const fileName = md5(filePath + dateStr) + fileType;\n    const path = ossBasePath + dirPath + nowDate + \"/\" + fileName\n    console.log(\"==== createOssPath ====filePath: \" + filePath + \"    path: \" + path);\n    return path;\n  }\n\n  /**\n   * Asynchronously uploading\n   */\n  asyncUpload(input) {\n    return AliyunOss.asyncUpload(this.config.bucketName, input.objectKey, input.filepath);\n  }\n\n}\n\n```\n上传进度：\n```\nsubscription = null;//上传进度的事件\n\n//上传进度\n  addProgressListener() {\n    if (!this.subscription) {//如果没有监听过，需要注册\n      const eventEmitter = new NativeEventEmitter(NativeModules.Oss);\n      this.subscription = eventEmitter.addListener(\n        'uploadProgress',\n        (res) => {//{\"currentSize\": \"153600\", \"totalSize\": \"155416\",\"filePath\":\"\"}\n})\n}\n componentWillUnmount() {\n    this.subscription && this.subscription.remove();\n    this.subscription = null;\n  }\n```\n\n## Contributing\n\nSee the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.\n\n## License\n\nMIT\n","readmeFilename":"README.md"}