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

Upload fails without error using custom directive #236

Closed
Floriferous opened this issue Aug 9, 2018 · 1 comment
Closed

Upload fails without error using custom directive #236

Floriferous opened this issue Aug 9, 2018 · 1 comment

Comments

@Floriferous
Copy link

I'm trying to upload a file to a custom object storage service, with the following directive:

import { MAX_FILE_SIZE, BUCKET_PATH } from 'core/api/files/fileConstants';

const API_KEY = 'my-key';
const SECRET_KEY = 'my-secret';

const CustomObjectStorage = {
  directiveMatch: {
    key: Function,
  },

  upload(method, directive, file, meta) {
    const fileKey = directive.key(file, meta);

    return {
      upload: BUCKET_PATH,
      download: `https://${BUCKET_PATH}/${fileKey}`,
      postData: [
        { name: 'accessKey', value: API_KEY },
        { name: 'secret_key', value: SECRET_KEY },
      ],
    };
  },

  maxSize: MAX_FILE_SIZE,
};

Then I start the upload like this:

this.uploader = new Slingshot.Upload(SLINGSHOT_DIRECTIVE_NAME, {
// My metadata..
  });

this.uploader.send(file, (error, downloadUrl) => {
// Error is undefined, yet file does not appear object storage
  if (error) {
   console.log('Error', error);
   this.setState({ error: error.message });
  } else {
   handleSave(file, downloadUrl);
  }
});

Any idea where the issue might lie, or how the error is being swallowed?

@Floriferous
Copy link
Author

As you can see in my code above, I didn't add https to my upload URL. Changing it to : https://${BUCKET_PATH} made the upload show proper errors again.

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

1 participant