Wim Leers: API-First Drupal maintenance support plans: file uploads!

Texas Born In 2000

Pixeldust Drupal Developers

Pixeldust is an expert software development agency and trusted Pantheon development partner specializing in Drupal Development, security, and support. In business since 2000, we have completed over 500 projects.

Pixeldust is Trusted by the Worlds Greatest Brands

Pixeldust offers premium Drupal development services.

We are committed to developing under Drupal best-practices, ensuring our clients have a stable, maintainable codebase.

Pixeldust is an expert software agency specializing in responsive frameworks, mobile applications, and online marketing services. Using the latest technologies, coupled with a healthy dose of imagination and expertise, we work closely with you to identify your needs, wants and provide a comprehensive, integrated solution to your online communication requirements.

Our Drupal developers are focused on quality, not quantity.

Our aim is to provide a responsive and personal approach to each project to ensure that our clients can benefit from their investment. We see each Drupal development project as an opportunity to grow your business—we aim to help you grow sales and improve retention while offering leading, aesthetically pleasing, and functional designs that suit your needs faultlessly.

What differentiates Pixeldust from other Drupal development is the effort to create a positive return on clients’ investments.

We have devoted years of effort to understanding the variables involved in user experience as well as online marketing strategies. Our team of inspired Web Designers, developers, and marketing specialists help to increase the exposure of your website, as well as provide a unique user engagement. Pixeldust is focused on creative and results-orientated solutions developed to maximize your website’s true earning and traffic potential.

Professional class Drupal Development is absolutely integral to the legitimacy and effectiveness of your online presence.

Our Developers boast superior technical know-how. In business since 1999, we have completed over 500 projects, giving us plenty of experience in developing beautiful, tailored websites while keeping your business interests in mind.

 

How does on-site Drupal SEO work?

Drupal 8 is the CMS of choice for many top enterprise websites because it was built from the jump the extensibility required to optimize every node, view, and code snippet for search engines. However, you have to know how to configure it. 

Search Engine Optimization (on-page Drupal SEO) has been around as long as search engines. If you run a website, you probably have at least a basic understanding of SEO. Drupal is phenomenal for SEO. We’ve worked in Drupal for 14 years and experienced firsthand how positively search engines respond to correctly configured Drupal sites. 

We have helped clients double their traffic, just by switching platforms. Drupal has some distinct technical advantages with on-site optimizations like RDF or AMP. The results are higher ranking, quicker, and more trafficked sites. Since Drupal 8 has scheduled feature releases every six months, you will be thinking in terms of months, not years, when new technology becomes a standard.

FREE Drupal maintenance support plans Security Audit

Why a Drupal site audit?

  • Security – Discover weaknesses in your Drupal implementation.
  • Performance – Identify areas where performance improvements can be made.
  • Site Acquisition – Do this before you buy a business as part of due diligence.
  • Implementation Verification – Check your site before it goes live to avoid critical issues that may appear under load.
  • Vendor Management – Make sure your current developer is doing a good job.
  • Support Transition – When moving to a new developer both sides need to know what they are working with.
FREE Drupal maintenance support plans Security Audit

Case Study: Mahindra USA Inc

Mahindra USA, Inc. manufactures agricultural machinery and equipment. They are the world’s largest selling tractor brand by volume, and the World’s number one tractor maker for over three decades.

Drupal Requirements

  • Support for a company-wide rebranding
  • Migration to a more robust and flexible platform in Drupal 8
  • Integration with third-party customer relationship management applications
  • Internationalization
  • Efficient scalability
  • Integration with sales SAS
  • Read Case Study

Inquiry

Call (512)730-0999 or submit an inquiry.
  • This field is for validation purposes and should be left unchanged.
Wim Leers: API-First Drupal maintenance support plans: file uploads!

30-Day Drupal SEO Blast – On-page and Off-page SEO Overhaul

We start every project off with an introductory discovery call with key stakeholders to create a project plan, establish key contacts, and plan credential transfers. 

Pixeldust’s 30-Day SEO Blast is a campaign to overhaul your Drupal site for immediate improvement in search engine rankings. Think of it as a 30-day boot camp for your website. The process is divided into two areas of focus: on-site and off-site.

On-Site Drupal SEO
On-site (or On-page) SEO:  Changes are made to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. On-site optimization ensures your site is configured to provide information in a way that meets Search engine standards for optimal indexing.  

Off-site White Hat Drupal SEO
Off-site (or Off-page) Drupal SEO is the process of making your site more visible to humans across the internet and increasing its relevance. 

Vigilant Drupal Support Plans

When you subscribe to our Unlimited Drupal Support Plan in Houston or Austin, you have the comfort of knowing our trusted team of Drupal admins is at the ready; waiting to fix errors, broken functionality, layout issues, and anything else the pops up. Some of our Unlimited clients don’t even have to log in to their sites anymore. Even if you just need an article posted, or a new product added to your shop, no worries, we got you. If it takes less than 30 minutes per issue, we will take care of it.

We start every project off with an introductory discovery call with key stakeholders to create a project plan, establish key contacts, and plan credential transfers. 

  • Unlimited Repairs & Fixes
  • Unlimited Update Tasks
  • FREE Set-up
  • Same-Day Security Updates
  • Monthly Module Updates
  • Monthly Broken Link Scan
  • Monthly Security Scan
  • Monthly Manual Site Check
  • Monthly Speed Test
  • Offline Updating
  • GIT Version Control
  • Detailed Work Notes
  • Testing After All Updates
  • Security Guarantee
  • Hack/Malware/Down Recovery
  • Uptime Monitoring
  • Daily Offsite Backups
  • Free Basic Website Hosting & SSL
  • Helpdesk Support
REQUEST FOR PROPOSAL

Need a custom quote?

Submit the RFP form below and we will send you a project proposal in 48 hours. If you like what you see, we can schedule a call to discuss the project in greater detail.

Step 1 of 2

  • Contact Information

Wim Leers: API-First Drupal maintenance support plans: file uploads!

Published on January 24, 2019

Drupal maintenance support plans 8’s REST API has been maturing steadily since the Drupal maintenance support plans 8.0.0 was released in November 2015. One of the big missing features has been file upload support. As of April 3 2018, Drupal maintenance support plans 8.6 will support it, when it ships in September 2018! See the change record for the practical consequences: https://www.drupal.org/node/2941420.

It doesn’t make sense for me to repeat what is already written in that change record: that already has both a tl;dr and a practical example.

What I’m going to do instead, is give you a high-level overview of what it took to get to this point: why it took so long, which considerations went into it, why this particular approach was chosen. You could read the entire issue (#1927648), but … it’s one of the longest issues in Drupal maintenance support plans history, at 572 comments1. You would probably need at least an entire workday to read it all! It’s also one of the longest commit messages ever, thanks to the many, many people who shaped it over the years:

Issue #1927648 by damiankloip, Wim Leers, marthinal, tedbow, Arla, alexpott, juampynr, garphy, bc, ibustos, eiriksm, larowlan, dawehner, gcardinal, vivekvpandya, kylebrowning, Sam152, neclimdul, pnagornyak, drnikki, gaurav.goyal, queenvictoria, kim.pepper, Berdir, clemens.tolboom, blainelang, moshe weitzman, linclark, webchick, Dave Reid, dabito, skyredwang, klausi, dagmar, gabesullice, pwolanin, amateescu, slashrsm, andypost, catch, aheimlich: Allow creation of file entities from binary data via REST requests

Thanks to all of you in that commit message!

I hope it can serve as a reference not just for people interested in Drupal maintenance support plans, but also for people outside the Drupal maintenance support plans community: there is no One Best Practice Way to handle file uploads for RESTful APIs. There is a surprising spectrum of approaches2. Some even avoid this problem space even entirely, by only allowing to “upload” files by sending a publicly accessible URL to the file. Read on if you’re interested. Otherwise, go and give it a try!

Design rationale

General:

Request with Content-Type: application/octet-stream aka “raw binary” as its body, because base64-encoded means 33% more bytes, implying both slower uploads and more memory consumption. Uploading videos (often hundreds of megabytes or even gigabytes) is not really feasible with base64 encoding.
Request header Content-Disposition: file; filename=”cat.jpg” to name the uploaded file. See the Mozilla docs. This also implies you can only upload one file per request. But of course, a client can issue multiple file upload requests in parallel, to achieve concurrent/batch uploading.
The two points above mean we reuse as much as possible from existing HTTP infrastructure.
Of course it does not make sense to have a Content-Type: application/octet-stream as the response. Usually, the response is of the same MIME type as the request. File uploads are the sensible exception.
This is meant for the raw file upload only; any metadata (for example: source or licensing) cannot be associated in this request: all you can provide is the name and the data for the file. To associate metadata, a second request to “upgrade” the raw file into something richer would be necessary. The performance benefit mentioned above more than makes up for the RTT of a second request in almost all cases.

PHP-specific:

php://input because otherwise limited by the PHP memory limit.

Drupal maintenance support plans-specific:

In the case of Drupal maintenance support plans, we know that it always represents files as File entities. They don’t contain metadata (fields), at least not with just Drupal maintenance support plans core; it’s the file fields (@FieldType=file or @FieldType=image) that contain the metadata (because the same image may need different captions depending on its use, for example).
When a file is uploaded for a field on a bundle on an entity type, a File entity is created with status=false. The response contains the serialized File entity.
You then need a second request to make the referencing entity “use” the File entity, which will cause the File entity to get status=true.
Validation: Drupal maintenance support plans core only has the infrastructure in place to use files in the context of an entity type/bundle’s file field (or derivatives thereof, such as image fields). This is why files can only be uploaded by specifying an entity type ID, bundle ID and field name: that’s the level where we have settings and validation logic in place. While not ideal, it’s pragmatic: first allowing generic file uploads would be a big undertaking and somewhat of a security nightmare.
Access control is similar: you need create access for the referencing entity type and field edit access for the file field.

Result

If we combine all these choices, then we end up with a new file_upload @RestResource plugin, which enables clients to upload a file:

by POSTing the file’s contents
to the path /file/upload/{entity_type_id}/{bundle}/{field_name}, which means that we’re uploading a file to be used by the file field of the specified entity type+bundle, and the settings/constraints of that field will be respected.
… don’t forget to include a ?_format URL query argument, this determines what format the response will be in
sending file data as a application/octet-stream binary data stream, that means with a Content-Type: application/octet-stream request header. (This allows uploads of an arbitrary size, including uploads larger than the PHP memory limit.)
and finally, naming the file using the Content-Disposition: file; filename=”filename.jpg” header
the five preceding steps result in a successfully uploaded file with status=false — all that remains is to perform a second request to actually start using the file in the referencing entity!

Four years in the making — summarizing 572 comments

From February 2013 until the end of March 2017, issue #1927648 mostly … lingered. On April 3 of 2017, damiankloip posted an initial patch for an approach he’d been working on for a while, thanks to Acquia (my employer) sponsoring his time. Exactly one year later his work is committed to Drupal maintenance support plans core. Shaped by the input of dozens of people! Just look at that commit message!

Want to actually read a summary of those 572 comments? I got you covered!

It currently is the fifth longest Drupal maintenance support plans core issue of all time! The first page, with ~300 comments, is >1 MB of HTML. ↩︎

Examples: Contentful, Twitter, Dropbox and others. ↩︎

API
Acquia
Drupal maintenance support plans

Source: New feed

Wim Leers: API-First Drupal maintenance support plans: file uploads!
Shopping Cart
There are no products in the cart!
Continue Shopping
0