Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot make it upload a video, are videos supported? #22

Open
andreacab opened this issue Feb 23, 2016 · 1 comment
Open

Cannot make it upload a video, are videos supported? #22

andreacab opened this issue Feb 23, 2016 · 1 comment

Comments

@andreacab
Copy link

Hi,
I get a *fileData = nil on line 93 of RCTFileTransfer.m:
NSData *fileData = [NSData dataWithContentsOfURL: dataUrl];

the object I am trying to send is:

let obj = {
  uri: "file://var/mobile/Containers/Data/Application/69982F3B-0575-41E1-91CA-DEC18B7F901D/Documents/videos/capturedvideo.MOV",
  uploadUrl: this.serverUrl + '/REST/medias/videos',
  fileName: 'test',
  fileKey: 'file',
  mimeType: 'multipart/form-data',
  headers: {
    'Accept': 'application/json',
    'Auth:' authToken
  }
}

I am new to iOS and Xcode, bare with me if that question is stupid, and my apologies in advance..

@sahlhoff
Copy link

Hi @andreacab,

I was able to upload a video by changing lines 55-57 to:

    /*
    CGImageRef fullScreenImageRef = [rep fullScreenImage];
    UIImage *image = [UIImage imageWithCGImage:fullScreenImageRef];
    NSData *fileData = UIImagePNGRepresentation(image);
    */

    Byte *buffer = (Byte*)malloc((NSUInteger)rep.size);
    NSUInteger buffered = [rep getBytes:buffer fromOffset:0.0 length:(NSUInteger)rep.size error:nil];
    NSData *fileData = [NSData dataWithBytesNoCopy:buffer length:buffered freeWhenDone:YES];

    [self sendData:fileData withOptions:input callback:callback];

Hopefully this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants