I am trying to figure out how to upload a file from IOS to Laravel Vapor using AlamoFire. There is little information on how to achieve this.

There is a npm file with the following seemingly simple code.

const axios = require('axios')

class Vapor
     * Store a file in S3 and return its UUID, key, and other information.
    async store(file, options = {}) {
        const response = await axios.post('/vapor/signed-storage-url', {
            'bucket': options.bucket || '',
            'content_type': options.contentType || file.type,
            'expires': options.expires || '',
            'visibility': options.visibility || ''
        }, {
            baseURL: options.baseURL || null,
            headers: options.headers || {}

        let headers = response.data.headers;

        if ('Host' in headers) {
            delete headers.Host;

        if (typeof options.progress === 'undefined') {
            options.progress = () => {};

        const cancelToken = options.cancelToken || ''

        await axios.put(response.data.url, file, {
            cancelToken: cancelToken,
            headers: headers,
            onUploadProgress: (progressEvent) => {
                options.progress(progressEvent.loaded / progressEvent.total);

        response.data.extension = file.name.split('.').pop()

        return response.data;

module.exports = new Vapor();

How that could translate into AlamoFire is beyond me. There is no information anywhere I could find on doing Native mobile uploads to a laravel vapor server.

Any help or guidance appreciated.

  • I don't know anything about AlamoFire, but you are hitting a specific route on your Laravel application to generate a signed URL that you can use to upload a file directly to an S3 bucket. You then send the location to your laravel application which can move that file from the temp directory of the bucket to a more permanent location. – James Mar 27 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.