Skip to content

Commit

Permalink
Merge pull request #133 from powerful23/s3_image_fix
Browse files Browse the repository at this point in the history
S3 image fix
  • Loading branch information
powerful23 authored Jan 17, 2018
2 parents e235705 + 1cdf05a commit 635bd5a
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/aws-amplify-react/__tests__/Storage/S3Album-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ describe('S3Album test', () => {

expect.assertions(2);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});

spyon.mockClear();
spyon2.mockClear();
Expand Down Expand Up @@ -244,7 +244,7 @@ describe('S3Album test', () => {

expect.assertions(3);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});
expect(spyon3).toBeCalledWith([{key: 'path2'}, 'data']);

spyon.mockClear();
Expand Down Expand Up @@ -292,7 +292,7 @@ describe('S3Album test', () => {

expect.assertions(2);
expect(spyon).toBeCalledWith({"file": "file", "name": "name", "size": "size", "type": "type"});
expect(spyon2).toBeCalledWith('path', 'file', {contentType: 'type'});
expect(spyon2).toBeCalledWith('path', 'file', {"contentType": "type", "level": "public", "track": undefined});

spyon.mockClear();
spyon2.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('S3Image', () => {
await s3Image.handlePick(data);

expect.assertions(2);
expect(spyon).toBeCalledWith('imgKey', 'file', {contentType: 'type'});
expect(spyon).toBeCalledWith('imgKey', 'file', {"contentType": "type", "level": "level", "track": undefined});
expect(spyon2).toBeCalled();

spyon.mockClear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('S3Text test', () => {
await s3Text.handlePick(data);

expect.assertions(2);
expect(spyon).toBeCalledWith('textKey', 'file', { contentType: 'type' });
expect(spyon).toBeCalledWith('textKey', 'file', {"contentType": "type", "level": "level", "track": undefined});
expect(spyon2).toBeCalled();

spyon.mockClear();
Expand Down
9 changes: 7 additions & 2 deletions packages/aws-amplify-react/dist/Storage/S3Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ var S3Album = function (_Component) {
onPick = _props.onPick,
onLoad = _props.onLoad,
onError = _props.onError,
track = _props.track;
track = _props.track,
level = _props.level;


if (onPick) {
Expand All @@ -129,7 +130,11 @@ var S3Album = function (_Component) {
type = data.type;

var key = path + this.getKey(data);
_awsAmplify.Storage.put(key, file, { contentType: type, track: track }).then(function (data) {
_awsAmplify.Storage.put(key, file, {
level: level ? level : 'public',
contentType: type,
track: track
}).then(function (data) {
logger.debug('handle pick data', data);
var items = _this2.state.items;

Expand Down
6 changes: 5 additions & 1 deletion packages/aws-amplify-react/dist/Storage/S3Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ var S3Image = function (_Component) {
type = data.type;

var key = imgKey || path + (0, _Common.calcKey)(data, fileToKey);
_awsAmplify.Storage.put(key, file, { contentType: type, track: track }).then(function (data) {
_awsAmplify.Storage.put(key, file, {
level: level ? level : 'public',
contentType: type,
track: track
}).then(function (data) {
logger.debug('handle pick data', data);
that.getImageSource(key, level, track);
})['catch'](function (err) {
Expand Down
6 changes: 5 additions & 1 deletion packages/aws-amplify-react/dist/Storage/S3Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ var S3Text = function (_Component) {
type = data.type;

var key = textKey || path + (0, _Common.calcKey)(data, fileToKey);
_awsAmplify.Storage.put(key, file, { contentType: type, track: track }).then(function (data) {
_awsAmplify.Storage.put(key, file, {
level: level ? level : 'public',
contentType: type,
track: track
}).then(function (data) {
logger.debug('handle pick data', data);
that.getText(key, level, track);
})['catch'](function (err) {
Expand Down
8 changes: 6 additions & 2 deletions packages/aws-amplify-react/src/Storage/S3Album.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,18 @@ export default class S3Album extends Component {

handlePick(data) {
const that = this;
const { onPick, onLoad, onError, track } = this.props;
const { onPick, onLoad, onError, track, level } = this.props;

if (onPick) { onPick(data); }

const path = this.props.path || '';
const { file, name, size, type } = data;
const key = path + this.getKey(data);
Storage.put(key, file, { contentType: type, track })
Storage.put(key, file, {
level: level? level: 'public',
contentType: type,
track
})
.then(data => {
logger.debug('handle pick data', data);
const { items } = this.state;
Expand Down
6 changes: 5 additions & 1 deletion packages/aws-amplify-react/src/Storage/S3Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ export default class S3Image extends Component {
const { imgKey, level, fileToKey, track } = this.props;
const { file, name, size, type } = data;
const key = imgKey || (path + calcKey(data, fileToKey));
Storage.put(key, file, { contentType: type, track })
Storage.put(key, file, {
level: level? level: 'public',
contentType: type,
track
})
.then(data => {
logger.debug('handle pick data', data);
that.getImageSource(key, level, track);
Expand Down
6 changes: 5 additions & 1 deletion packages/aws-amplify-react/src/Storage/S3Text.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ export default class S3Text extends Component {
const { textKey, level, fileToKey, track } = this.props;
const { file, name, size, type } = data;
const key = textKey || (path + calcKey(data, fileToKey));
Storage.put(key, file, { contentType: type, track })
Storage.put(key, file, {
level: level? level: 'public',
contentType: type,
track
})
.then(data => {
logger.debug('handle pick data', data);
that.getText(key, level, track);
Expand Down

0 comments on commit 635bd5a

Please sign in to comment.