1

Can someone please advise on how to return a SAS signature for fine-uploader so that I do not get the following error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:5000' is therefore not allowed access. The response had HTTP status code 400.

currently my fine-uploader instance is set up as following:

var uploader = new qq.azure.FineUploader({

        debug: true,
        element: document.getElementById("fine-uploader"),
        request: {
            endpoint: 'https://asilverman.blob.core.windows.net/picdepot'
        },
        cors: {
            //all requests are expected to be cross-domain requests
            expected: true,
            sendCredentials: true

        },
        signature: {
            customHeaders: {'Access-Control-Allow-Origin': true},
            endpoint: '/sas'
        },
        uploadSuccess: {
            endpoint: ''
        },
        scaling: {
            sendOriginal: false,

            sizes: [
                {name: "", maxSize: 800}
            ]
        },
        validation: {
            allowedExtensions: ['jpeg', 'jpg', 'png']
        }

    });

The server side that is handling the requests is doing the following:

@login_required
@app.route('/sas', methods=['GET'])
def sas():
    container_name = 'https://asilverman.blob.core.windows.net/picdepot'
    sas = SharedAccessSignature(account_name=app.config['AZURE_ACCOUNT'], account_key=app.config['AZURE_KEY'])
    access_policy = AccessPolicy()
    access_policy.start = (datetime.datetime.utcnow() + datetime.timedelta(seconds=-120)).strftime('%Y-%m-%dT%H:%M:%SZ')
    access_policy.expiry = (datetime.datetime.utcnow() + datetime.timedelta(seconds=120)).strftime('%Y-%m-%dT%H:%M:%SZ')
    access_policy.permission = 'w'
    sap = SharedAccessPolicy(access_policy)
    sas_token = sas.generate_signed_query_string(container_name, 'c', sap)
    return request.args['bloburi'] + '?' + sas_token + '&' + 'comp=list&restype=container'

Currently I am getting the following error (from chrome dev tools):

XMLHttpRequest cannot load https://asilverman.blob.core.windows.net/picdepot/8622a0a3-efb6-478b-891a-8…Mj1uvtPisX6s=&sr=c&se=2015-08-23T22%3A35%3A47Z&comp=list&restype=container. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:5000' is therefore not allowed access. The response had HTTP status code 400.

1 Answer 1

1

Sounds like your storage container isn't properly configured. You'll need to ensure it includes appropriate CORS headers in responses. This is covered in detail in the fine uploader azure docs.

Sign up to request clarification or add additional context in comments.

1 Comment

Could you please help me decipher how to configure the container so that it includes the appropriate CORS headers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.