
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
rn-buyme-saver-media
Advanced tools
rn-buyme-saver-media
— это нативный модуль для React Native, позволяющий скачивать файлы из сети и сохранять их в галерею на устройствах iOS и Android. Модуль поддерживает отслеживание прогресса загрузки.
yarn add rn-buyme-saver-media
expo install expo-dev-client
cd ios
pod install
Чтобы модуль мог сохранять файлы в галерею, добавьте следующие разрешения в Info.plist:
<key>NSPhotoLibraryUsageDescription</key>
<string>Требуется доступ к галерее для сохранения изображений</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Требуется разрешение для добавления изображений в галерею</string>
Импортируйте и используйте функцию downloadFileToGallery, передавая URL файла и коллбэк для отслеживания прогресса загрузки.
import React, { useState } from 'react';
import { Button, View, Text } from 'react-native';
import { downloadFileToGallery } from 'rn-buyme-saver-media';
export default function App() {
const [progress, setProgress] = useState(0);
const handleDownload = () => {
downloadFileToGallery("https://example.com/image.jpg", setProgress)
.then(() => alert("Download completed!"))
.catch(error => alert(`Download failed: ${error.message}`));
};
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Button title="Download File" onPress={handleDownload} />
<Text>{`Download Progress: ${progress}%`}</Text>
</View>
);
}
downloadFileToGallery(url: string, onProgress: (progress: number) => void): Promise<void>
url
- URL загружаемого файла.onProgress
- функция коллбэк, вызываемая с текущим прогрессом загрузки в процентах.Для работы на iOS с сохранением файлов в галерею модуль использует PHPhotoLibrary, поэтому требуется разрешение на доступ к фото-библиотеке.
Для вопросов и предложений свяжитесь с нами.
For managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release. If you follow the link and there is no documentation available then this library is not yet usable within managed projects — it is likely to be included in an upcoming Expo SDK release.
For bare React Native projects, you must ensure that you have installed and configured the expo
package before continuing.
Run npx pod-install
after installing the npm package.
FAQs
Downloader any medias with process callback
We found that rn-buyme-saver-media demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.