Closed Floriferous closed 5 years ago
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?
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.
https
upload
https://${BUCKET_PATH}
I'm trying to upload a file to a custom object storage service, with the following directive:
Then I start the upload like this:
Any idea where the issue might lie, or how the error is being swallowed?