Skip to content

Commit 3fd1b81

Browse files
authored
fix: 修复 react-native-create-thumbnail 网络请求异常问题 (#6)
1 parent 77cb722 commit 3fd1b81

File tree

8 files changed

+27
-155
lines changed

8 files changed

+27
-155
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

-25
This file was deleted.

.github/ISSUE_TEMPLATE/stale.yml

-17
This file was deleted.

README.md

+7-85
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,13 @@
1-
# react-native-create-thumbnail
1+
# @react-native-oh-tpl/react-native-create-thumbnail
22

3-
iOS/Android thumbnail generator with storage/cache management and support for both local and remote videos. `react-native-create-thumbnail` is a wrapper around
4-
[`AVAssetImageGenerator`](https://developer.apple.com/documentation/avfoundation/avassetimagegenerator?language=objc) (iOS) and [`MediaMetadataRetriever`](https://developer.android.com/reference/android/media/MediaMetadataRetriever) (Android)
3+
本项目基于 [react-native-create-thumbnail](https://github.com/souvik-ghosh/react-native-create-thumbnail)
54

6-
[![npm version](https://img.shields.io/npm/v/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![npm downloads](https://img.shields.io/npm/dm/react-native-create-thumbnail.svg)](https://npmjs.com/package/react-native-create-thumbnail) [![Maintenance Status](https://img.shields.io/badge/maintenance-active-green.svg)](#maintenance-status)
5+
## 文档地址 Documentation URL
76

8-
## Getting started
7+
[中文 Chinese](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-create-thumbnail.md)
98

10-
1. Install library from `npm`
9+
[英文 English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-en/react-native-create-thumbnail.md)
1110

12-
```bash
13-
npm i react-native-create-thumbnail
14-
```
11+
## 请悉知 Acknowledgements
1512

16-
or
17-
18-
```bash
19-
yarn add react-native-create-thumbnail
20-
```
21-
22-
2. Link native code
23-
24-
With autolinking (react-native 0.60+)
25-
26-
```bash
27-
cd ios && pod install
28-
```
29-
30-
Pre 0.60
31-
32-
```bash
33-
react-native link react-native-create-thumbnail
34-
```
35-
36-
## Usage
37-
38-
```javascript
39-
import { createThumbnail } from "react-native-create-thumbnail";
40-
41-
createThumbnail({
42-
url: '<path to video file>',
43-
timeStamp: 10000,
44-
})
45-
.then(response => console.log({ response }))
46-
.catch(err => console.log({ err }));
47-
```
48-
49-
## Request Object
50-
51-
| Property | Type | Description |
52-
| --------- | :-----------------------: | :------------------------------------------------------------------------ |
53-
| url | `String` (required) | Path to video file (local or remote) |
54-
| timeStamp | `Number` (default `0`) | Thumbnail timestamp (in milliseconds) |
55-
| format | `String` (default `jpeg`) | Thumbnail format, can be one of: `jpeg`, or `png` |
56-
| dirSize | `Number` (default `100`) | Maximum size of the cache directory (in megabytes). When this directory is full, the previously generated thumbnails will be deleted to clear about half of it's size. |
57-
| headers | `Object` | Headers to load the video with. e.g. `{ Authorization: 'someAuthToken' }` |
58-
| cacheName | `String` (optional) | Cache name for this thumbnail to avoid duplicate generation. If specified, and a thumbnail already exists with the same cache name, it will be returned instead of generating a new one. |
59-
60-
## Response Object
61-
62-
| Property | Type | Description |
63-
| -------- | :------: | :-------------------------- |
64-
| path | `String` | Path to generated thumbnail |
65-
| size | `Number` | Size (in bytes) of thumbnail|
66-
| mime | `String` | Mimetype of thumbnail |
67-
| width | `Number` | Thumbnail width |
68-
| height | `Number` | Thumbnail height |
69-
70-
#### Notes
71-
72-
Requires following Permissions on android
73-
74-
```bash
75-
READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE
76-
```
77-
78-
#### Limitations
79-
80-
- Remote videos aren't supported on android sdk_version < 14.
81-
- This is a **Native Module**, so it won't work in expo managed projects.
82-
- This library heavily depends on the native API's to generate the thumbnails. Thus it can only generate from the video formats/codecs that are supported by the device's OS.
83-
84-
#### Credits
85-
86-
- [`react-native-thumbnail`](https://www.npmjs.com/package/react-native-thumbnail) - A great source of inspiration
87-
- This project was bootstrapped with [`create-react-native-module`](https://github.com/brodybits/create-react-native-module)
88-
89-
#### Maintenance Status
90-
91-
**Active:** Bug reports, feature requests and pull requests are welcome.
13+
本项目基于 [The MIT License (MIT)](https://github.com/souvik-ghosh/react-native-create-thumbnail/blob/master/LICENSE) ,请自由地享受和参与开源。

harmony/createThumbnail.har

608 Bytes
Binary file not shown.
+15-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
1+
/**
2+
* Use these variables when you tailor your ArkTS code. They must be of the const type.
3+
*/
4+
export const HAR_VERSION = '2.0.0-0.0.1';
5+
export const BUILD_MODE_NAME = 'debug';
6+
export const DEBUG = true;
7+
export const TARGET_NAME = 'default';
8+
9+
/**
10+
* BuildProfile Class is used only for compatibility purposes.
11+
*/
112
export default class BuildProfile {
2-
static readonly HAR_VERSION = '2.0.0-0.0.1';
3-
static readonly BUILD_MODE_NAME = 'debug';
4-
static readonly DEBUG = true;
5-
static readonly TARGET_NAME = 'default';
13+
static readonly HAR_VERSION = HAR_VERSION;
14+
static readonly BUILD_MODE_NAME = BUILD_MODE_NAME;
15+
static readonly DEBUG = DEBUG;
16+
static readonly TARGET_NAME = TARGET_NAME;
617
}

harmony/createThumbnail/oh-package-lock.json5

-18
This file was deleted.

harmony/createThumbnail/src/main/ets/download/RequestDownload.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export default class RequestDownload {
5959
let downloadConfig: request.agent.Config = {
6060
action: request.agent.Action.DOWNLOAD,
6161
url: url,
62-
method: 'POST',
6362
title: 'download',
6463
mode: request.agent.Mode.FOREGROUND,
6564
network: request.agent.Network.ANY,

package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"keywords": [
1313
"react-native"
1414
],
15-
"harmony":{
16-
"alias":"react-native-create-thumbnail",
15+
"harmony": {
16+
"alias": "react-native-create-thumbnail",
1717
"codegenConfig": {
1818
"specPaths": [
1919
"./src"
2020
]
2121
}
22-
},
22+
},
2323
"author": {
2424
"name": "Souvik Ghosh",
2525
"email": "emailtosvk@gmail.com"
@@ -29,6 +29,6 @@
2929
"readmeFilename": "README.md",
3030
"peerDependencies": {
3131
"react-native": ">=0.59.0",
32-
"react-native-create-thumbnail": "2.0.0"
32+
"react-native-create-thumbnail": "2.0.0"
3333
}
34-
}
34+
}

0 commit comments

Comments
 (0)