GithubHelp home page GithubHelp logo

jedt / react-native-file-transfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alinz/react-native-file-transfer

0.0 2.0 1.0 23 KB

react-native plugin for uploading files with multipart/form-data requests

License: MIT License

Objective-C 100.00%

react-native-file-transfer's Introduction

react-native-file-transfer npm version

This little plugin lets you easily upload files from your photo library to a web server using a standard multipart/form-data POST request. It does not incorporate the tranfer of photo library images data from Objective-C to JavaScript (which is slow). The request are being made directly from Objective-C.

installation

  1. npm install react-native-file-transfer;
  2. right click on Libraries
  3. select Add Files to ... option
  4. navigate to node_modules/react-native-file-transfer/lib/ios and add RCTFileTransfer.xcodeproj
  5. on navigator click on your project name and on Target select your project name.
  6. Select Build Phase and add RCTFileTransfer.o to your Link Binary With Libraries

how to use it

When you properly add the RCTFileTransfer.m file to your xcode project you may now use it in the js files. Example usage:

var { NativeModules } = require('react-native');
var obj = {
    uri, // either an 'assets-library' url (for files from photo library) or an image dataURL
    uploadUrl,
    fileName,
    mimeType,
    headers,
    data: {
        // whatever properties you wish to send in the request
        // along with the uploaded file
    }
};
NativeModules.FileTransfer.upload(obj, (err, res) => {
    // handle response
    // it is an object with 'status' and 'data' properties
    // if the file path protocol is not supported the status will be 0
    // and the request won't be made at all
});

pull-requests welcome

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.