GithubHelp home page GithubHelp logo

vinzscam / react-native-tus-client Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 31.0 62 KB

React Native client for the tus resumable upload protocol.

License: MIT License

Java 45.43% Objective-C 26.59% Ruby 4.08% JavaScript 23.90%
android file-upload ios javascript react-library react-native tus upload upload-file uploader

react-native-tus-client's Introduction

Hi there ๐Ÿ‘‹

react-native-tus-client's People

Contributors

julianocomg avatar vinzscam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

react-native-tus-client's Issues

Change "endpoint" to "uploadUrl" on IOS

Can someone help me on how to change the endpoint to uploadUrl, VIMEO will return 405 when using the endpoint and will work when using uploadUrl. I verified it by using the tus/tus-js-client on IOS.

null error when trying to start uploading

When trying to upload

try {
        const upload = new Upload(response.uri, {
          endpoint: 'http://XXX.XXX.X.XXXX:3001/uploads',
          onError: error => console.error('error', error),
          onSuccess: (upload) => {
            console.error('Upload completed. File url:', upload.url);
          },
          onProgress: (uploaded, total) => console.error('errorrr'),
        })
        upload.start().then(el => {
          console.error('el', el)
        }).catch(e => {
          console.error('strange error',e);              //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
        })

      } catch (e) {
        console.error(e)
      }

the output is stange error null.

I have had a loot at the source and it's more likely the problem comes from


  private createUpload (): Promise<void> {
    return new Promise((resolve, reject) => {

      const { metadata, headers, endpoint } = this.options;
      const settings = { metadata, headers, endpoint };

      RNTusClient.createUpload(
        this.file,
        settings,
        (uploadId: string) => {
          this.uploadId = uploadId;
          if (uploadId == null) {
            reject(null);                      //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
          } else {
            this.subscribe();
            resolve();
          }
        }
      );
    });
  }

Does anybody have an idea how to fix that ?

No such file or directory Error

Hello everyone;
I want to use tus-client to upload my videos on a remote endpoint. but after choosing a video from my android device and when I start upload it shows an Error which says
Failed because: Error: file:/storage/emulated/0/Movies/c5326f6c-dc42-4eb0-97c8-040233f08352.mp4 (No such file or directory)
is there any solution for that or could you help me to find the right way for uploading my files?
best regards;

my react-native version is 0.60.6
the video uri is like: file:/storage/emulated/0/Movies/c5326f6c-dc42-4eb0-97c8-040233f08352.mp4
and the way I'm trying to send my files is:

let uploadOptions = {
"url": my_EndpointUri,
"authorization": ${authorization_key},
"acceptLanguage": 'en',
"uuid": "salam"//ImageUri.name + ImageUri.size + ImageUri.lastModified,
};
const upload = new Upload(ImageUri, {
fingerprint: () => {
return uploadOptions.uuid;
},
resume: true,
chunkSize: 1048576, // 1MB
retryDelays: [0, 500, 1000, 1500, 2000, 2500],
endpoint: uploadOptions.url,
headers: {
'Authorization': uploadOptions.authorization,
'Accept-Language': uploadOptions.acceptLanguage,
},
metadata: {
filename: "video.mp4",
filetype: "video/mp4"
},
onError: function (error) {
console.log("Failed because: " + error)
},
onProgress: function (bytesUploaded, bytesTotal) {
var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)
console.log(bytesUploaded, bytesTotal, percentage + "%")
},
onSuccess: function () {
console.log("Download %s from %s", upload.file.name, upload.url)
}
});
await upload.start();
}

Anyone have issues uploading through an iOS Simulator? Works fine in production

I'm having issues with the Simulator where file uploads just don't work. Meanwhile production builds are able to upload files no problem. Ideally, I can upload files locally to do feature development faster.

I'm slowly running out of ideas for what could be the problem. I've narrowed it down to something to do with TUSKit.
https://github.com/tus/TUSKit/blob/1.4.2/TUSKit/TUSData.m#L164-L170

In the logs I see:

<TUSResumableUpload.m:(547)> Resuming upload to http://localhost:3000/tus_uploads/files/547291eb8834d6b4771692ab3bf6208b with id 3A802AA9-4C1B-4C00-B30B-E1D0E149771E from offset 0
<TUSData.m:(122)> TUSData stream opened
<TUSData.m:(139)> Reading 32768 bytes from 0 to 32768 until 580198
<TUSData.m:(166)> TUSData stream error (null)

Testing against https://master.tus.io makes no difference

<TUSResumableUpload.m:(547)> Resuming upload to https://master.tus.io/files/86b6afe994c191e87af5a7dc76f04e27+D5qDDrw4o9xSqahOrqXx2wt.lObIfo3iuNAHStq_QMhrd0CpqqYoqympv5x5U_EceIm7C1xJn9hjlCwlePqTK4BnZaMG55Hc.Dvb2ibWYj8jID0eHE8xFY6B6TiDuKhE with id D6045D90-D394-4C6F-AB3D-CB31CB492250 from offset 0
<TUSData.m:(122)> TUSData stream opened
<TUSData.m:(139)> Reading 32768 bytes from 0 to 32768 until 277804
<TUSData.m:(166)> TUSData stream error (null)

which obviously is no help at all.
Curious if anyone else has had problems with file uploads in the iOS Simulator. I don't see why a fix would be needed on the library since it works in production, I'd imagine it's got something to do with my Simulator configuration, so that's the angle I'm investigating

Some details of my environment:

"expo": "50.0.8",
"react-native": "0.73.4",
"react-native-tus-client": "1.1.0"

Running on iPhone 15 Pro Simulator - iOS 17.2

io.tus.java.client.ProtocolException: unexpected status code (403) while creating upload

Hi, I tried to use this library to upload a video file to my youtube account, the file is a .mp4 on my android phone, when I executed the following code, I got this error:
io.tus.java.client.ProtocolException: unexpected status code (403) while creating upload

Here is the code:
`

  let uploadUrl = "https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status&uploadType=resumable&key=xxxxxxxx";

   let filePath='/storage/emulated/0/DCIM/Camera/test.mp4';

  const upload = new Upload(filePath, {
    endpoint: uploadUrl,
    retryDelays: [0, 1000, 3000, 5000],
    headers: {'Authorization': 'Bearer ' + mytoken},
    metadata: {
      filename: filePath,
      filetype: 'application/octet-stream', 
      snippet:
      {  "title":"Testing",
         "description":"This is to show an example", 
         "categoryId":"22",
         "tags":["Cut","Cat"]
      },
      status:
      {  "privacyStatus":"unlisted",
         "embeddable":true,
         "license":"youtube"
      }
    },
    onError: (error) => {
      console.log("Upload error:", error);
    },
    onProgress: (uploadedBytes, totalBytes) => {
      console.log("uploadedBytes, totalBytes: ", uploadedBytes, totalBytes);
    },
    onSuccess: () => {
      console.log("Upload upload:", upload);
    }
  });
  upload.start();

`

System:
OS: macOS 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 163.24 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.4.0 - /usr/local/bin/node
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 27.0.3, 28.0.2, 28.0.3
System Images: android-22 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.1 AI-173.4907809
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.6 => 16.8.6
react-native: ^0.60.0 => 0.60.0
npmGlobalPackages:
react-native-asset: 2.0.0
react-native-cli: 2.0.1
react-native-cn-richtext-editor: 1.0.33
react-native-git-upgrade: 0.2.7

error Error: Error while resuming the upload

When I close the App and open again....in create a func to continue the Upload with the same file source....but I got this error and the Upload start in 0% again:

error Error: Error while resuming the upload
    at posicionpicker.js:51
    at MessageQueue.__invokeCallback (MessageQueue.js:400)
    at MessageQueue.js:139
    at MessageQueue.__guardSafe (MessageQueue.js:316)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (MessageQueue.js:138)
    at debuggerWorker.js:72

Can you help me?

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.