mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-06 22:37:14 +08:00
Summary:
With this in place, it's possible to upload a picture from the `CameraRoll` to Parse, for instance:
xhr = new XMLHttpRequest();
xhr.onload = function() {
data = JSON.parse(xhr.responseText);
var parseFile = new Parse.File(data.name);
parseFile._url = data.url;
callback(parseFile);
};
xhr.setRequestHeader('X-Parse-Application-Id', appID);
xhr.setRequestHeader('X-Parse-JavaScript-Key', appKey);
xhr.open('POST', 'https://api.parse.com/1/files/image.jpg');
// assetURI as provided e.g. by the CameraRoll API
xhr.send(new NativeFile(assetURI));
Closes https://github.com/facebook/react-native/pull/1357
Github Author: Philipp von Weitershausen <philikon@fb.com>
Test Plan: Imported from GitHub, without a `Test Plan:` line.
29 lines
738 B
Objective-C
29 lines
738 B
Objective-C
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
@class ALAssetsLibrary;
|
|
@class UIImage;
|
|
|
|
@interface RCTImageLoader : NSObject
|
|
|
|
+ (ALAssetsLibrary *)assetsLibrary;
|
|
|
|
/**
|
|
* Can be called from any thread.
|
|
* Will always call callback on main thread.
|
|
*/
|
|
+ (void)loadImageWithTag:(NSString *)tag
|
|
callback:(void (^)(NSError *error, id /* UIImage or CAAnimation */ image))callback;
|
|
|
|
+ (BOOL)isSystemImageURI:(NSString *)uri;
|
|
|
|
@end
|