Issue with "Contenful" API: Storing images is randomly failing

237 views Asked by At

we are using the Contentful API with Angular 1.

When we try to store an image (file size does not matter) the Contentful API randomly throws an error:

Uncaught (in promise) Error: Asset is taking longer then expected to process.

As it is working fine most of the time I think there might not be an issue with our code. Maybe someone of you guys experienced the same issue and could solve it?

That's our factory:

ContentFulFactory.createAssetFromFiles()
.then((space) => {
    space.createAsset({
        fields: {
            title: {
                'en': $scope.file.title
            },
            file: {
                'en': {
                    contentType: $scope.file.image.type,
                    fileName: $scope.file.image.$ngfName,
                    upload: data.data.url
                }
            }
        }
    })
        .then((asset) => {
            /**
             * Processing asset
             */
            console.log('processing...', asset);
            return asset.processForLocale('en', { processingCheckWait: 100, processingCheckRetries: 20 });
        })
        .then((asset) => {
            /**
             * Publishing asset
             */
            console.log('publishing...', asset);
            return asset.publish();
        })
        .then((asset) => {
            console.log(asset);
            $scope.isProgress = false;
            $uibModalInstance.close();
        })
});

Thanks in advance!

0

There are 0 answers