Are you in the quite specific scenario of wanting to upload photos to a rails backend with a react front end but don't know how? I've got you cover...
For further actions, you may consider blocking this person and/or reporting abuse
I followed all the steps but I get the following error please help
ActionDispatch::Http::Parameters::ParseError (767: unexpected token at '------WebKitFormBoundaryxaYAnLtlkajqzq9E
Did you able to solve that problem?
Yes it's already solved I forgot to leave a comment
How did you solve that?. Can I have the repo please?.
in my case the problem was in the headers I had not noticed that content type application json was being sent basically it is not necessary to send something in the header unless you need token or something similar since when sending the form data it reads it as multipart
I'm sorry but the repository is private to the company where I work
After making post request from my frontend I am getting SystemStackError (stack level too deep):
Could you share the code snippet in which you create the object and make the request?
Can we talk somewhere privately so that I can share you everything?
Started POST "/requests" for ::1 at 2023-06-03 12:37:57 +0200
ActiveRecord::SchemaMigration Pluck (0.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
Processing by RequestsController#create as /
Parameters: {"request"=>{"owner_id"=>"14", "address"=>"Sioux Falls Regional Airport, North Jaycee Lane, Sioux Falls, SD, USA", "title"=>"ede", "description"=>"ededed", "request_type"=>"One Time Help", "image"=>#, @original_filename="aboutPic.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"request[image]\"; filename=\"aboutPic.jpg\"\r\nContent-Type: image/jpeg\r\n">}}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 14], ["LIMIT", 1]]
TRANSACTION (0.2ms) begin transaction
↳ app/controllers/requests_controller.rb:39:in
create'
create'User Load (0.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT ? [["id", 14], ["LIMIT", 1]]
↳ app/controllers/requests_controller.rb:39:in
Request Create (3.0ms) INSERT INTO "requests" ("request_type", "request_status", "title", "description", "address", "longitude", "latitude", "created_at", "updated_at", "image", "owner_id") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["request_type", "One Time Help"], ["request_status", nil], ["title", "ede"], ["description", "ededed"], ["address", "Sioux Falls Regional Airport, 2801 N Jaycee Ln, Sioux Falls, SD 57104, USA"], ["longitude", -96.7402171], ["latitude", 43.5828065], ["created_at", "2023-06-03 10:37:58.226690"], ["updated_at", "2023-06-03 10:37:58.226690"], ["image", nil], ["owner_id", 14]]
↳ app/controllers/requests_controller.rb:39:in
create'
create'ActiveStorage::Attachment Load (0.8ms) SELECT "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = ? AND "active_storage_attachments"."record_type" = ? AND "active_storage_attachments"."name" = ? LIMIT ? [["record_id", 65], ["record_type", "Request"], ["name", "image"], ["LIMIT", 1]]
↳ app/controllers/requests_controller.rb:39:in
ActiveStorage::Blob Create (0.5ms) INSERT INTO "active_storage_blobs" ("key", "filename", "content_type", "metadata", "service_name", "byte_size", "checksum", "created_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?) [["key", "u894h1xx89cd5uainuz6sov5elg2"], ["filename", "aboutPic.jpg"], ["content_type", "image/png"], ["metadata", "{\"identified\":true}"], ["service_name", "local"], ["byte_size", 160361], ["checksum", "K9W6jdq1ahsDFH5hD9ID4A=="], ["created_at", "2023-06-03 10:37:58.241950"]]
↳ app/controllers/requests_controller.rb:39:in
create'
create'ActiveStorage::Attachment Create (0.3ms) INSERT INTO "active_storage_attachments" ("name", "record_type", "record_id", "blob_id", "created_at") VALUES (?, ?, ?, ?, ?) [["name", "image"], ["record_type", "Request"], ["record_id", 65], ["blob_id", 23], ["created_at", "2023-06-03 10:37:58.245722"]]
↳ app/controllers/requests_controller.rb:39:in
Request Update (0.5ms) UPDATE "requests" SET "updated_at" = ? WHERE "requests"."id" = ? [["updated_at", "2023-06-03 10:37:58.249002"], ["id", 65]]
↳ app/controllers/requests_controller.rb:39:in
create'
create'TRANSACTION (0.9ms) commit transaction
↳ app/controllers/requests_controller.rb:39:in
Disk Storage (2.0ms) Uploaded file to key: u894h1xx89cd5uainuz6sov5elg2 (checksum: K9W6jdq1ahsDFH5hD9ID4A==)
[ActiveJob] Enqueued ActiveStorage::AnalyzeJob (Job ID: 29b97ba1-7686-457b-9472-3bf3f5c5eeca) to Async(default) with arguments: #>
Completed 500 Internal Server Error in 442ms (ActiveRecord: 7.3ms | Allocations: 63482)
SystemStackError (stack level too deep):
app/controllers/requests_controller.rb:40:in `create'
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] ActiveStorage::Blob Load (0.1ms) SELECT "active_storage_blobs".* FROM "active_storage_blobs" WHERE "active_storage_blobs"."id" = ? LIMIT ? [["id", 23], ["LIMIT", 1]]
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] Performing ActiveStorage::AnalyzeJob (Job ID: 29b97ba1-7686-457b-9472-3bf3f5c5eeca) from Async(default) enqueued at 2023-06-03T10:37:58Z with arguments: #>
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] Skipping image analysis because the ruby-vips gem isn't installed
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] TRANSACTION (0.1ms) begin transaction
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] ActiveStorage::Blob Update (0.4ms) UPDATE "active_storage_blobs" SET "metadata" = ? WHERE "active_storage_blobs"."id" = ? [["metadata", "{\"identified\":true,\"analyzed\":true}"], ["id", 23]]
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] TRANSACTION (0.6ms) commit transaction
[ActiveJob] [ActiveStorage::AnalyzeJob] [29b97ba1-7686-457b-9472-3bf3f5c5eeca] Performed ActiveStorage::AnalyzeJob (Job ID: 29b97ba1-7686-457b-9472-3bf3f5c5eeca) from Async(default) in 120.74ms
Of course, I'll leave you my email f.pino.perez.dev@gmail.com, I don't think a live conversation will be fruitful since my English is horrible xd
i have just sent you an email, please do check there.