react-native-file-transfer
react-native-file-transfer copied to clipboard
Cannot make it upload a video, are videos supported?
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..
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.