- Rails 7.0.2
- stimulus js
- importmaps
- dropzone.js
- direct upload ActiveStorage
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
This is simple implementation of technologies in hobby project of mine built in Rails7 where I need direct upload to S3.
В результате будет 2 react проекта на 1 сервере доступных по разным ссылкам
import React from 'react'; | |
import { | |
View, | |
Text, | |
TextInput, | |
Button, | |
StyleSheet, | |
} from 'react-native'; | |
import { Picker } from '@react-native-picker/picker'; | |
import { useForm, Controller } from 'react-hook-form'; |
%sl-alert.popup-toast{id: id, type: type, open: false, duration: duration, closable: true} | |
%sl-icon{slot: "icon", name: icon} | |
- if title.present? | |
%strong= title | |
%br | |
= text |
Install, build and debug a react native app in WSL2 (Windows Subsystem for Linux) and Ubuntu.
import * as humps from 'humps'; | |
/** | |
* Decamelize form data keys and values | |
* @param {FormData} formData | |
* @param {Object} [options] | |
* @return {FormData} | |
*/ | |
export const decamelizeFormDataKeys = (formData, options) => { | |
const decamelizedFormData = new FormData(); |
<%= form_with(model: billboard) do |form| %> | |
<%= tag.div class: "dropzone", data: { controller: "dropzone", dropzone_param_name_value: "billboard[images][]", dropzone_url_value: rails_direct_uploads_url, dropzone_accepted_files_value: "image/*", dropzone_max_files_value: 3, dropzone_max_filesize_value: 0.300 } do %> | |
<div class="dz-default dz-message flex flex-col items-center"> | |
<%= image_tag "upload.svg", size: 28, class: "colorize-black", aria: { hidden: true } %> | |
<h5 class="font-semibold mbs-4">Drop files here or click to upload.</h5> | |
<p class="text-sm text-subtle">Upload up to 10 files.</p> | |
</div> | |
<% end %> | |
<div class="inline-flex items-center mbs-2 mie-1"> |
Converts all document formats using LibreOffice first to PDF and then to an image, using build-in pdf previwer of ActiveStorage
unoconv
, a command line tool which uses libreoffice, e.g. apt install unoconv
apt install poppler-utils
import axios from 'axios'; | |
const instance = axios.create({ | |
baseURL: 'http://localhost:5000' | |
}); | |
const sleepRequest = (milliseconds, originalRequest) => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => resolve(instance(originalRequest)), milliseconds); | |
}); |