Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an asset example fails on process_file #209

Open
gilest opened this issue Oct 19, 2019 · 0 comments
Open

Creating an asset example fails on process_file #209

gilest opened this issue Oct 19, 2019 · 0 comments

Comments

@gilest
Copy link

gilest commented Oct 19, 2019

Following along from README.md.

    image_file = Contentful::Management::File.new
    image_file.properties[:contentType] = 'image/jpeg'
    image_file.properties[:fileName] = "#{@artist.slug}.jpg"
    image_file.properties[:upload] = @artist.image

    asset = @environment.assets.create(title: @artist.slug, description: '', file: image_file)
    asset.save

    asset.process_file

Fails with this error:

Message: Validation error
Details:
	* Name: required - Path: '["fields", "file", "en-US", "upload"]' - Value: ''
	* Name: required - Path: '["fields", "file", "en-US", "uploadFrom"]' - Value: ''
Request ID: xyz
/Users/giles/.gem/ruby/2.3.1/gems/contentful-management-2.11.0/lib/contentful/management/client.rb:390:in `execute_request'

It seems that some properties are missing on the asset.file object.

The following snippet completes without error:

    image_file = Contentful::Management::File.new
    image_file.properties[:contentType] = 'image/jpeg'
    image_file.properties[:fileName] = "#{@artist.slug}.jpg"
    image_file.properties[:upload] = @artist.image

    asset = @environment.assets.create(title: @artist.slug, description: '', file: image_file)

    asset.file.properties[:contentType] = 'image/jpeg'
    asset.file.properties[:fileName] = "#{@artist.slug}.jpg"
    asset.file.properties[:upload] = @artist.image

    asset.save

    asset.process_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant