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

S3 image fix #133

Merged
merged 4 commits into from
Jan 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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